Question

Can anyone help me on how this error came up

There is already an open DataReader associated with this Connection which must be closed first.

the error fails when it trying to read this code.

transConn = mySqlConn.BeginTransaction(IsolationLevel.ReadCommitted)

Is there is a connection between the Datareader and in initializing the transaction?

Can anyone help me on how can I fix this bugs.

Thanks peeps! :)

Was it helpful?

Solution

Close the DataReader before you begin the transaction.

See here: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.close.aspx

It says:

"You must explicitly call the Close method when you are through using the SqlDataReader to use the associated SqlConnection for any other purpose."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top