I want insert data from CSV file to SQL table. Here is my code I don't know how to go further
var readcsv = File.ReadAllText(filepath);
string[] csvfilerecord = readcsv.Split('
');
foreach (var row in csvfilerecord)
{
if (!string.IsNullOrEmpty(row))
{
foreach (var cell in row.Split(','))
{
var cards = new Cards
{
//What to do here to assign data to each column
};
}
}
}
here is my csv file data
12345,cvv,18-april,name,country,address,state,city,dob,zipcode,phone,email,10
12345,cvv,18-april,name,country,address,state,city,dob,zipcode,phone,email,10
class Definition
public string nummber { get; set; }
public string cvv { get; set; }
public string expDate { get; set; }
public string name { get; set; }
public string country { get; set; }
public string address { get; set; }
public string state { get; set; }
public string dob { get; set; }
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…