473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 1547
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Puvendran | last post by:
Hi, We have encountered deadlock on a table which is used to generate sequential numbers for different categories eg typical entries Category Value TRADE_NO ...
3
by: heynothanks | last post by:
(MSSQL2000) I have read the transaction/locking sections in the MS-help, online and several books. What I want to understand is the transaction behavior in single statements . If I have a...
16
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
5
by: Ritesh | last post by:
Hi All, According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint,...
8
by: dan.c.roth | last post by:
Hi I am having a debate with one of the Postgres developers (Tom Lane) according to him ms-sql does not implement predicate locking(SERIALIZABLE). Where predicate locking is defined as (from...
2
by: qhjghz | last post by:
I have two tables say A_prod & A_staging. Now, I need to insert those rows in A_prod which are present in A_staging but not in A_prod. We can do this in chiefly two ways :- 1. We can simply...
7
dlite922
by: dlite922 | last post by:
I need to do some sort of Locking mechanism at interface level, instead of DB Level. I know how MySQL table locking works, but that won't work in my scenerio. Requirements: When someone is...
3
by: Brad Pears | last post by:
I have a vb.net 2005 app that asks for a job number. After the job number has been entered, I run an SQL 2000 stored procedure that selects the appropriate row from the Jobs table. I do not want to...
0
by: Caper | last post by:
Hello everyone, I am a bit confused about Innodb deadlock and the "SELECT…FOR UPDATE” statement. 1. Here is a deadlock example 1) Create actor table CREATE TABLE actor(actor_id INT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.