|
-
Apr 18th, 2005, 06:43 AM
#1
Thread Starter
Member
how to close datareader...
hi everyone
i am tryin gto fill a couple of listboxes using stored procedures...and i m passing the sqlcommand object directly to listbox, instead of using datareader object...like this:
//
cmdInsert = New SqlCommand("Exec proc_po_number", objSql)
lstPONo.DataSource = cmdInsert.ExecuteReader
lstPONo.DataTextField = "po_number"
lstPONo.DataBind()
cmdInsert = New SqlCommand("Exec proc_wo_number", objSql)
lstWONo.DataSource = cmdInsert.ExecuteReader
lstWONo.DataTextField = "wo_number"
lstWONo.DataBind()
//
...now the problem occurs after secong ExecuteReader is called...it gives following error:
//There is already an open DataReader associated with this Connection which must be closed first. //
can anyone plz tel how can i close a datareader object if i m not using any.
if i go the other way, i.e. by using dtrList( a datareder object) and use:
//
dtrList=cmdInsert.ExecuteReader
lstPONo.DataSource=dtrList
//
..then i can easily call dtrPO.close and then rest of code will work fine....but someone plz tell me how to do it without using dtrPO.
thnx.
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
|