0
我想用OLEDB讀取Excel文件,但是當在查詢中插入參數,我有這樣的OleDb例外:參數傳遞到Excel查詢在asp.net
沒有值給出一個或多個所需的參數
代碼
string conn = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES"";", opFileImport.FileName);
string sql = "Select CODICE_FISCALE From [Parte_4$] ";
sql += "where CODICE_FISCALE = ?";
using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter())
{
dataAdapter.SelectCommand = new OleDbCommand(sql, excelConn);
dataAdapter.SelectCommand.Parameters.Add(new OleDbParameter("Param1", strCodFisc));
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
}