If the connection assigned to the command is in a locally suspended transaction, ExecuteReader requires that the command have a transaction. The Transaction property of the command has not been initialized

Source: Internet
Author: User

{system.invalidoperationexception: If the connection assigned to the command is in a locally pending transaction, ExecuteReader requires the command to have a transaction. The Transaction property of the command has not been initialized.
In System.Data.OleDb.OleDbConnectionInternal.ValidateTransaction (oledbtransaction transaction, String method)
In System.Data.OleDb.OleDbConnection.ValidateTransaction (oledbtransaction transaction, String method)
In System.Data.OleDb.OleDbCommand.ValidateConnectionAndTransaction (String method)
In System.Data.OleDb.OleDbCommand.ExecuteReaderInternal (CommandBehavior behavior, String method)
In System.Data.OleDb.OleDbCommand.ExecuteReader (CommandBehavior behavior)
In System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader (CommandBehavior behavior)
In System.Data.Common.DbDataAdapter.FillInternal (DataSet DataSet, datatable[] DataTables, Int32 Startrecord, Int32 MaxRecords, String srctable, IDbCommand command, CommandBehavior behavior)
In System.Data.Common.DbDataAdapter.Fill (DataSet DataSet, Int32 Startrecord, Int32 maxrecords, String srctable, IDbCommand command, CommandBehavior behavior)
In System.Data.Common.DbDataAdapter.Fill (DataSet DataSet, String srctable)
In Ytud. Public.DB.GetDataTable (String Sql, OleDbConnection dbcon) location F:\CsProjects\yytd\standrd2014-9-6\ytud\Public\DB.cs: Line number 57
In Ytud. Mainfrm.importdb_importproject (String srcdbfilepath) position F:\CsProjects\yytd\standrd2014-9-6\ytud\Main.cs: line number 2084}

This is because the connection object used by the OleDbCommand object opens the transaction, but does not specify the transaction for the transaction property of the OleDbCommand object.

If the connection assigned to the command is in a locally suspended transaction, ExecuteReader requires that the command have a transaction. The Transaction property of the command has not been initialized

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.