【问题标题】:Oledb Exception - No value given for one or more required parametersOledb 异常 - 没有为一个或多个必需参数提供值
【发布时间】:2013-09-06 04:51:10
【问题描述】:

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


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

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      放置您的列名

      例如

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

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

      【讨论】:

      • 我尝试在 [] 之间放置列名,但仍然出现相同的错误。我还检查了所有列名是否存在,甚至变量“appointmentReportsFileName”(这是我的 csv 文件名)也具有所有值。当我使用:“SELECT [a_id], [EpisodeId] as EpisodeId, ....”时,它给出了“由查询定义的 SELECT 列表中的别名 'EpisodeId' 引起的循环引用”的异常。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多