|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
data reader error...is already an open DataReader associated with this Command which must be closed first. at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command) at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at BDB.AddressEditor.RedoData() in It happens after I perform an executenonquery, then try to reload data into a dataset based on the table i just used the non query on to insert a new row into it... nothing in this is databound, why would i get this error? i dont even use data readers in my program (i understand that ADO.NET does in the background though) so how can i go about debugging this? Please post a short example that reproduces the problem.
Show quote "Brian Henry" <nospam@nospam.com> wrote in message news:O2LF0CVbGHA.4564@TK2MSFTNGP05.phx.gbl... >I keep getting this error message...System.InvalidOperationException: There >is already an open DataReader associated with this Command which must be >closed first. at >System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand >command) at >System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String >method, SqlCommand command) at >System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean >async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior >cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, >DbAsyncResult result) at >System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior >cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) >at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, >String method) at >System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior >behavior) at >System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior >behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, >DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String >srcTable, IDbCommand command, CommandBehavior behavior) at >System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, >Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior >behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String >srcTable) at BDB.AddressEditor.RedoData() in > > It happens after I perform an executenonquery, then try to reload data > into a dataset based on the table i just used the non query on to insert a > new row into it... nothing in this is databound, why would i get this > error? i dont even use data readers in my program (i understand that > ADO.NET does in the background though) so how can i go about debugging > this? > Dim cmdAdd As New SqlClient.SqlCommand("BENESP_CARR_AddCarrier",
BDB.database.dbConnectionData) cmdAdd.CommandType = CommandType.StoredProcedure cmdAdd.Parameters.AddWithValue("@name", sPartnerName.Trim) cmdAdd.Parameters.Add("@CarrierID", SqlDbType.BigInt) cmdAdd.Parameters("@CarrierID").Direction = ParameterDirection.Output cmdAdd.Parameters.AddWithValue("@Active", True) cmdAdd.ExecuteNonQuery() iCarrierID = DirectCast(cmdAdd.Parameters("@CarrierID").Value, Int64) Debug.Write("New Business Partner Added: " & iCarrierID.ToString) cmdAdd.Dispose() that is my query executed then doign this.... Dim cmdGetPhoneNumbers As New SqlClient.SqlCommand(_SelectProc, database.dbConnectionData) Dim daSQLAdp As New SqlClient.SqlDataAdapter(cmdGetPhoneNumbers) Dim PrimaryKey(0) As DataColumn ' sql command initialization stuff cmdGetPhoneNumbers.Parameters.Add(_keyColumn, Data.SqlDbType.BigInt).Value = _ItemID cmdGetPhoneNumbers.CommandType = CommandType.StoredProcedure dsPhone.Clear() ' make sure we have a clear data set before filling it with data daSQLAdp.Fill(dsPhone, "PhoneNumbers") ' set the primary key column so we can use it later PrimaryKey(0) = dsPhone.Tables("PhoneNumbers").Columns("PhoneID") dsPhone.Tables("PhoneNumbers").PrimaryKey = PrimaryKey fails at the fill with that exception... no other data queries are done beween the two sections Have you tried running your program on different machines? Using a different
database server? I couldn't see anything in the code you posted that would point to a problem, and I haven't seen this error message when there wasn't in fact an open datareader somewhere. Show quote "Brian Henry" <nospam@nospam.com> wrote in message news:ed9kwSVbGHA.2368@TK2MSFTNGP03.phx.gbl... > Dim cmdAdd As New SqlClient.SqlCommand("BENESP_CARR_AddCarrier", > BDB.database.dbConnectionData) > > cmdAdd.CommandType = CommandType.StoredProcedure > > cmdAdd.Parameters.AddWithValue("@name", sPartnerName.Trim) > > cmdAdd.Parameters.Add("@CarrierID", SqlDbType.BigInt) > > cmdAdd.Parameters("@CarrierID").Direction = ParameterDirection.Output > > cmdAdd.Parameters.AddWithValue("@Active", True) > > cmdAdd.ExecuteNonQuery() > > iCarrierID = DirectCast(cmdAdd.Parameters("@CarrierID").Value, Int64) > > Debug.Write("New Business Partner Added: " & iCarrierID.ToString) > > cmdAdd.Dispose() > > > > that is my query executed then doign this.... > > > > Dim cmdGetPhoneNumbers As New SqlClient.SqlCommand(_SelectProc, > database.dbConnectionData) > > Dim daSQLAdp As New SqlClient.SqlDataAdapter(cmdGetPhoneNumbers) > > Dim PrimaryKey(0) As DataColumn > > ' sql command initialization stuff > > cmdGetPhoneNumbers.Parameters.Add(_keyColumn, Data.SqlDbType.BigInt).Value > = _ItemID > > cmdGetPhoneNumbers.CommandType = CommandType.StoredProcedure > > dsPhone.Clear() ' make sure we have a clear data set before filling it > with data > > daSQLAdp.Fill(dsPhone, "PhoneNumbers") > > ' set the primary key column so we can use it later > > PrimaryKey(0) = dsPhone.Tables("PhoneNumbers").Columns("PhoneID") > > dsPhone.Tables("PhoneNumbers").PrimaryKey = PrimaryKey > > > > fails at the fill with that exception... no other data queries are done > beween the two sections > > |
|||||||||||||||||||||||