我试图在asp.net c#中使用Microsoft.Jet.OLEDB.4.0读取一个csv文件,但是我收到的错误是“没有给出一个或多个必需参数的值。”
my select query :
string query = string.Concat("SELECT a_id, EpisodeId, Logged, [appintmentfollowporreferral] as Appointment, AppointmentType, AppointmentDateAndTime, AppointmentWith, Outcome, RTWStatus, Completed FROM " + appointmentReportsFileName);
here is the code that i am using to read the csv file :
string connString = string.Concat("Provider=Microsoft.Jet.OLEDB.4.0;", "Data Source=", filePath, ";", "Extended Properties=\"text;HDR=Yes;FMT=D=Delimited(,)\"");
//create an OleDbDataAdapter to execute the query
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
//fill the DataTable
dAdapter.Fill(dTable);
dAdapter.Dispose();
这是我想读的csv文件:
答案 0 :(得分:0)
放置列名称
e.g。
string query = string.Concat("SELECT [a_id], EpisodeId, [Logged],
[appintmentfollowporreferral] as [Appointment], AppointmentType, AppointmentDateAndTime,
AppointmentWith, [Outcome], RTWStatus, Completed FROM " + appointmentReportsFileName);
同时检查是否存在所有给定列或表名变量(appointmentReportsFileName
)是否具有有效值