1

Microsoft Access 2010 をデータ ソースとして使用して小さなインベントリ アプリケーションを作成しています。私の接続文字列は次のようになります。

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

ただし、エラーObject Invalid or no longer setを取得するレコードを更新すると。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();
    }
4

0 に答える 0