DataAdapters from Compnent Designer Problems

B

Bob Day

using VS2003, vb net, sql msde...

I am deeply frustrated with DataAdapters (ie DA) created in the Component
Designer. After considerable time spent, it was confirmed to me via this
newsgroup that there is a problem with DA not releasing their connection to
the pool, so if you do 100 DA.UPDATES you then crash because you run out of
connections. I increased the Max Pool = 800 to get around this (in the SQL
Connection String).

Is there a URL that explains all knows problems with the Component Designer?

But now, more problems...
For example, I have two threads. I can have either one of them by iteself
add 200 rows in a loop very quickly to the DataSource (ie add the row to the
DataSet and UPDATE to the datasource, 1 row at a time). If I have both
threads doing the same thing, it fails withing the first 5 rows, with the
error message below. The 200 row loop has nothing to do with it, I will get
this error message at some pont in the normal running of the program (just
not as quickly). I don't use a DataReader anywhere in the program, and
check the connection to make sure it is closed before the update. Error
Message:
"A first chance exception of type System.InvalidOperationException occurred
in System.data.dll.
Additional Information: There is already an open DataReader associated with
this connection which must be closed first."



Below is some code from the Update (notice how I am trying to close
connections).:

Select Case gcConnection.State

Case Not ConnectionState.Closed

Stop

gcConnection.Close()

End Select

' code to fill DT_With_Changes

' Update DataSource from Dataset for this table

Rows_Updated = SQL_Data_Adapter.Update(DT_With_Changes)

Any ideas what is going on?

Thanks!

Bob Day
 
K

Kevin Yu [MSFT]

Hi Bob,

Based on my understanding, you're adding data to the same DataSet from two
threads. When developing a program which contains multi-threads, we must
make sure to lock some public resources which both threads can access.
Locking prevents another thread from accessing when one thread is using the
object. Please try to check if you have locked the DataSet before accessing
it. In C#, you can use lock statement to create a critical area, and lock
specified object. In VB, you can use the System.Threading.Monitor class's
Enter and Exit method to achieve this. For more information, please refer
to the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemthreadingmonitormemberstopic.asp

If you have locked the resources already, is it convenient for you to paste
some of your code here?

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Bob Day" <[email protected]>
| Subject: DataAdapters from Compnent Designer Problems
| Date: Wed, 12 Nov 2003 17:35:38 -0500
| Lines: 58
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: dhcp065-029-073-128.indy.rr.com 65.29.73.128
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:66160
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| using VS2003, vb net, sql msde...
|
| I am deeply frustrated with DataAdapters (ie DA) created in the Component
| Designer. After considerable time spent, it was confirmed to me via this
| newsgroup that there is a problem with DA not releasing their connection
to
| the pool, so if you do 100 DA.UPDATES you then crash because you run out
of
| connections. I increased the Max Pool = 800 to get around this (in the
SQL
| Connection String).
|
| Is there a URL that explains all knows problems with the Component
Designer?
|
| But now, more problems...
| For example, I have two threads. I can have either one of them by iteself
| add 200 rows in a loop very quickly to the DataSource (ie add the row to
the
| DataSet and UPDATE to the datasource, 1 row at a time). If I have both
| threads doing the same thing, it fails withing the first 5 rows, with the
| error message below. The 200 row loop has nothing to do with it, I will
get
| this error message at some pont in the normal running of the program (just
| not as quickly). I don't use a DataReader anywhere in the program, and
| check the connection to make sure it is closed before the update. Error
| Message:
| "A first chance exception of type System.InvalidOperationException
occurred
| in System.data.dll.
| Additional Information: There is already an open DataReader associated
with
| this connection which must be closed first."
|
|
|
| Below is some code from the Update (notice how I am trying to close
| connections).:
|
| Select Case gcConnection.State
|
| Case Not ConnectionState.Closed
|
| Stop
|
| gcConnection.Close()
|
| End Select
|
| ' code to fill DT_With_Changes
|
| ' Update DataSource from Dataset for this table
|
| Rows_Updated = SQL_Data_Adapter.Update(DT_With_Changes)
|
| Any ideas what is going on?
|
| Thanks!
|
| Bob Day
|
|
|
|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top