I have csv files which I would like to dump into a db. so I crated a loop of the files, and inside the loop I have created a list called data for each line
StreamReader file = new StreamReader(itemChecked.ToString());//read the file
while ((line = file.ReadLine()) != null)
{
if (start_flag == true) // start processing the numbers, get the real data
{
List<string> data = new List<string>();
data.AddRange(line.Replace("\"", "").Split(',').AsEnumerable());
}
}
so far so good.
Now I want to insert the list data into the database. The list is quite large. I don't want to type every single one of them like so:
insert into table1 (tablenames) values (a, b, c on and on)
How can I loop the list and insert the data into the database?