SQL Reader Help

  • Thread starter Thread starter Dharmen
  • Start date Start date
D

Dharmen

Hey Guys!
Im trying to read data from a SQL server database to 2 datalists. When
an item from 1st datalist is selected it should load the coreesponding
values to the 2nd datalist. The first one works fine but it doesnt load the
corresponding values to the second datalist. I just found out the reason
why...its coz im using execute reader in 2 different areas...one to read the
values for the first datalist and one for the second. I dont know how to fix
this. Please help me. I also need to load the 3rd corresponding value to may
be a repeater or a label. So please help me with this....

If u have MSN ID it would be great....please email me ur MSN ID to
idhayam20(at)yahoo.com (this is not my ID though)

Thanks!
 
--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
Dharmen said:
Hey Guys!
Im trying to read data from a SQL server database to 2 datalists. When
an item from 1st datalist is selected it should load the coreesponding
values to the 2nd datalist. The first one works fine but it doesnt load the
corresponding values to the second datalist. I just found out the reason
why...its coz im using execute reader in 2 different areas...one to read the
values for the first datalist and one for the second. I dont know how to fix
this. Please help me. I also need to load the 3rd corresponding value to may
be a repeater or a label. So please help me with this....

If u have MSN ID it would be great....please email me ur MSN ID to
idhayam20(at)yahoo.com (this is not my ID though)

Thanks!
If you use two or three readers, each one having its own connection, you
shouldn't have any problem. You issue is probably that you are trying to
use the same connectoin for different readers and/or you aren't closing the
connection when you are finished. However, this sounds like a terrible way
to accomplish what you are doing. If you fire a reader each time the user
clicks, you'll invariably make more trips to the db than necessary and in
many instances you may well requery data that you already had. Instead, I'd
pull over two datatables and creat a DataView on the data corresponding to
the second list. When the .SelectedValue of the first one changes, you can
set the rowfilter property of the second dataview to its key value so that
only the corresponding records show
http://www.knowdotnet.com/dataaccess.html. Or you could use a dataRelation
http://www.knowdotnet.com/articles/datarelation.html. Either way i'd look
to using the disconnected objects to handle this so I don't make unnecessary
trips to the db. If you have to do it the current way you mention, just
make sure you have seperate connections for each one or at least make sure
you close each connection before trying to use it again. But using the
disconnected stuff, you'll make fewer trips, have less network traffifc,
less stress on the db, reduce your potential for network and connection
errors and get a lot better performance.

HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
 
Thank You so much William!
I used ur second solution for now and it worked!...(which u didnt
recommend)..I will try the dataview solution soon...
Thanks a lot!
-Seelan
 
Back
Top