oledbexception对象无效或不再在MS Access 2010中设置

时间:2012-09-14 04:11:49

标签: ms-access-2010 oledbconnection oledbcommand

我正在使用Microsoft Access 2010创建小型Inventory应用程序作为数据源。我的连接字符串如下所示:

<add name="ApplicationServices"
      connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\nityaprakash\Documents\NPSInventory.accdb"
      providerName="System.Data.OleDb" />

但是在更新任何记录时出现错误对象无效或不再设置。我正在使用OleDbCommand更新记录,将简单更新查询作为CommandType.Text传递。

   try
    {
       _dataAccess = DataAccess.GetInstance())

            _dataAccess.OpenConnection();

            string command_ = "UPDATE Inventory SET Item = 'MyItem', Description = 'Desc', Category = '', Location = '', Manufacturer = 'CELLo', Model = 'cell101', ReorderLevel = 10, TargetStockLevel = 200, BalanceQuantity =150, Discontinued = 0, Comments = 'Comment' Where ID = 9;";
            IDbCommand cmd_ = _dataAccess.GetCommandFor(command_, CommandType.Text);

            cmd_.ExecuteNonQuery();



    }
    finally
    {
        if (_dataAccess != null)
            _dataAccess.CloseConnection();
    }

0 个答案:

没有答案