TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mehmet Yilmaz
NA
29
2.2k
C# dding data from parameter "access" to "Datatable"
Oct 15 2018 4:45 PM
Hi,
The following is added to the acces table with "using" in the code painted with the red. this takes a long time if the number of lines is too high. so how can I translate this section to the "Datatable" object
Exam :
DataTable dt = new DataTable();
dt.Columns.Add("periodclumb", typeof(string));
....
??????
void start()
{
for (int i = 0; i < datagrid1.RowCount; i++)
{
if (datagrid1.Rows[i] != null && datagrid1.Rows[i].Cells[1].Value != null)
{
DateTime d = DateTime.Parse(datagrid1.Rows[i].Cells[1].Value.ToString());
Insertrow(d.ToString("dd.MM.yyyy"));
}
}
void Insertrow(string cell)
{ DateTime period;
string ncell = cell.Replace('.', '-');
if (DateTime.TryParseExact(ncell, "dd-MM-yyyy", null, DateTimeStyles.None, out period))
{ Insertperiod(period.AddMonths(-1)); Insertperiod(period); } }
void Insertperiod(DateTime period)
{
using (var conn = new OleDbConnection("Provider=" + "Microsoft.Jet.OLEDB.4.0" + "; Data Source=" + mdbpatch))
using (var cmd1 = conn.CreateCommand())
{
cmd1.Connection.Open();
cmd1.CommandText = "insert into billtable (periodclumb) values (?)";
cmd1.Parameters.AddWithValue("?", period.ToString("MM/yyyy").Replace('.', '/'));
cmd1.ExecuteNonQuery();
}
}
Reply
Answers (
2
)
How do i refer to this textbox if it dosnt exist yet?
Singleton design pattern(C# WPF)