當我試圖更新使用OleDbConnection
MS Access數據庫(.mdb
文件),我得到這個錯誤更新MS Access數據庫:在下面的代碼使用OLEDB連接
Microsoft JET Database Engine
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at CostEstimate.Form1.processdbBtn_Click(Object sender, EventArgs e) in C:\Users\sy\Visual Studio 2008\Projects\demo\demo\Form1.cs :line 137
137線是指command.ExecuteNonQuery();
請在下面找到的代碼,並幫我找出這個問題
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=C:\Users\sy\Visual Studio 2008\Projects\demo\demo\CE_Database.mdb;";
conn.Open();
OleDbCommand command = new OleDbCommand();
string[][] allData = [[1,'a'],[2,'b'],[3,'c']]
foreach (string[] individualData in allData)
{
command.CommandText = @"insert into CETable(JobCode,JobName) Values(individualData[0],individualData[1])";
command.Connection = conn;
command.ExecuteNonQuery();
}
conn.Close();
JET是否支持傳入的OLE-DB? – 2013-04-26 04:09:22