你好我正在使用OleDB,这个代码得到的错误是没有给出一个或多个参数的值,即使我只更新1个单元格并给出1个值有人知道为什么吗?此外,我有类似的代码,但另一个正在工作,而这一个不是
public void excelUpdateNPP()
{
//excelConnectionStringRD = "Provider=Microsoft.ACE.OLEDB.12.0;" +
//"Data Source=" + RDloc + ";" +
//"Extended Properties=Excel 12.0";
//xlConnRD = new OleDbConnection(excelConnectionStringRD);
//xlCmdRD = xlConnRD.CreateCommand();
int col_product = dataGridViewForm1.Columns["New Product Program"].Index;
int npp_col = dataGridViewForm1.Columns["NPI Phase"].Index + 2;
string npp_string = ExcelColumnFromNumber(npp_col);
try
{
foreach (DataGridViewRow row in dataGridViewForm1.Rows)
{
xlConnRD.Open();
if (row.Cells[col_product].Value.ToString().Equals(product_name)) ;
{
int cellrow = (row.Index + bigBusinessRow + 1);
xlCmdRD.CommandText = "UPDATE [Sheet$" + npp_string + cellrow.ToString() + ":" + npp_string + cellrow.ToString() + "] SET F1 = '" + cbNPI.Text + "'";
xlCmdRD.ExecuteNonQuery();
}
xlConnRD.Close();
}
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}