Hi,
I'm trying to run an insert statement continously for 24 hrs, data is coming from different Ip/PORT (100). Could somebody please help me by checking my codes if there's any way I can do to improved my locking so that I'll not be able to get the message below. Before the execution of insert is done another thread is getting the adapter that's why the current insert always fails.
CODE:
DBCommand = new SqlCommand(strInsert,DBConnect);
Monitor.Exit(DBCommand);
try
{
if (DBConnect.State.ToString() == "Closed")
{DBConnect.Open();}
DEBUG.PRINT("BEFORE EXECUTE:" + straddr);
DBCommand.ExecuteNonQuery();
DEBUG.PRINT("AFTER EXECUTE:" + straddr);
DBCommand.Dispose();
DBCommand.Connection.Close();
DBConnect.Close();
Monitor.Exit(DBCommand);
}
TRACE DATA FOR CLEARER INFORMATION:
BEFORE EXECUTE: <b>172.30.57.125:21307</b>
INSERT ERROR1 <b>172.30.98.249:20417</b>==? insert into rop values
System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.
at System.Data.SqlClient.SqlCommand.ValidateCommand(S tring method, Boolean executing)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at ossrop.Services.ossAdminService.SaveToSQLDB(String strFile, String strOpt, String straddr)
AFTER EXECUTE: <b>172.30.57.125:21307</b>