469,626 Members | 1,016 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

locking problem in insert statement

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>
Nov 16 '05 #1
1 1437
is this a typo of sorts?
you have two exit monitors instead of an enter and an exit.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"dabuskol" <an*******@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
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>

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Puvendran | last post: by
3 posts views Thread by heynothanks | last post: by
16 posts views Thread by Nid | last post: by
5 posts views Thread by Ritesh | last post: by
8 posts views Thread by dan.c.roth | last post: by
2 posts views Thread by qhjghz | last post: by
3 posts views Thread by Brad Pears | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.