|
-
May 30th, 2003, 09:31 AM
#1
Thread Starter
Hyperactive Member
Looping and updating simulatneously problem
I have a problem.
I am using the OLEDataProvider class.
By looping through a table of records via the data reader, I use a connection item called "conn".
Within this loop, when I find a condition which matches my condition, I then update that particular record (I want to). I am updating using an OLEDBcommand, which also makes use of the connection iteam "conn". This is where the problem lies. I can't update within this loop becoz the loop itself is using this connection item. I am try ing to look for a way to avoid creating a separate connection item for updating purposes. Does anybody know a way out of this?
-
May 30th, 2003, 09:44 AM
#2
PowerPoster
Use a dataadapter to fill a 'disconnected' dataset. This will keep your connection free. The datareader is what is blocking it.
-
May 30th, 2003, 11:11 AM
#3
Thread Starter
Hyperactive Member
hm.......i don't quite get wat u said...
do i maintain the data reader for th eloop?
by filling a 'disconnected dataset', i don't understand how this enables me to update my database...could u help me out?
-
May 30th, 2003, 12:14 PM
#4
PowerPoster
The datareader is connected to the db while it is being used, therefore you can't update at the same time until the datareader is done giving you data. If you use a dataset to hold the same information that the datareader is holding, you can loop through the dataset and update because it isn't using a connection, all the data is brought back from the database and stored in the dataset itself.
-
May 30th, 2003, 10:23 PM
#5
Thread Starter
Hyperactive Member
ok, so u r saying that in this case, it would be better if i do not use a data reader?
if that is so, er.......ok, so i fill the dataset using a data adapter.
How do I loop through a data set? could u give me an example?
hm......when updating, how is it done if i am merely updating the data which the data set holds? how do i reflect the changes back to the databsae if it is 'disc onnected'?
could u giv e me an example as well?
-
May 31st, 2003, 11:00 AM
#6
Thread Starter
Hyperactive Member
er.......really would appreciate it if someone could help me as i really am in need of it! i still don't know how to solve this problem!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|