oleDbDataAdapter /Connection
-
A quick question about the oleDbDataAdapter. Is it a good idea to use these in threads to update a dataset? I notice that if I am running concurrent threads where each uses an adapter to fill a dataset, the first thread will work, and the second thread (different adapter and dataset, but same connection) will run, but nothing will be put into my dataset. Obviously the second thread cannot fill its dataset because the connection is open from the first thread. I understand why the adapter isn't filling my dataset, but I'm sort of shocked it would just skip the fill command without giving any indication that it did so. What is the int that the Fill function returns anyway? Can I use that number to determine if the function actually did its job? And if so, what would be the best way to go about using adapters in threads...right now I'm locking them down until the connection is free...is there a better way? Just curious, thanks a bunch! :-D
-
A quick question about the oleDbDataAdapter. Is it a good idea to use these in threads to update a dataset? I notice that if I am running concurrent threads where each uses an adapter to fill a dataset, the first thread will work, and the second thread (different adapter and dataset, but same connection) will run, but nothing will be put into my dataset. Obviously the second thread cannot fill its dataset because the connection is open from the first thread. I understand why the adapter isn't filling my dataset, but I'm sort of shocked it would just skip the fill command without giving any indication that it did so. What is the int that the Fill function returns anyway? Can I use that number to determine if the function actually did its job? And if so, what would be the best way to go about using adapters in threads...right now I'm locking them down until the connection is free...is there a better way? Just curious, thanks a bunch! :-D
When using the
System.Data.OleDb
classes, your options are limited because of the abstraction that OLE DB provides (basically the whole purpose of its existence). With theSystem.Data.SqlClient
classes this really isn't a problem. You might check if the OLE DB provider for whatever you're connecting to supports connection pooling or limitations that might help in this situation. The properties that you pass to your connection string are used by the OLE DB provider for your data source. Other than that, locking against a shared resource (such as a static property of some class) or using a delegation approach to create and execute commands and / or adapters (and synchronizing them internally) are about your only options. It's the OLE DB provider for your data source here that is the problem.Microsoft MVP, Visual C# My Articles