Posted on: 11/7/2014 5:40:14 AM | Views : 531

I used the code from .NET MVC, Upload a CSV file to Database with Bulk upload to upload, read and insert to DB the csv file. My problem now is how can I pass the values from the csv file to the specific database table columns.
string Feedback = string.Empty; string line = string.Empty; string[] strArray; DataTable dt = new DataTable(); DataRow row; Regex r = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"); StreamReader sr = new StreamReader(fileName);
line = sr.ReadLine(); strArray = r.Split(line); Array.ForEach(strArray, s => dt.Columns.Add(new DataColumn()));
while ((line = sr.ReadLine()) != null) {
Go to the complete details ...