Oledb 异常 - 没有为一个或多个必需参数提供值

本文关键字:参数 一个 异常 Oledb | 更新日期: 2023-09-27 18:30:32

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


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

Oledb 异常 - 没有为一个或多个必需参数提供值

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

放置列名

例如

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

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