1

我正在尝试在 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 文件:


请有人帮我解决这个问题....

4

2 回答 2

0

放置您的列名

例如

string query = string.Concat("SELECT [a_id], EpisodeId, [Logged], 
[appintmentfollowporreferral] as [Appointment], AppointmentType, AppointmentDateAndTime,
AppointmentWith, [Outcome], RTWStatus, Completed FROM " + appointmentReportsFileName);

还要检查所有给定的列是否存在或表名变量 ( appointmentReportsFileName) 是否具有有效值

于 2013-09-06T05:13:12.383 回答
0

设置断点检查您在查询字符串中的内容以应用于您的数据库

于 2013-09-06T09:39:26.710 回答