controls sharing one OleDbDataReader

S

Steven K

Hello,

I am using the following code which works. My question is does the
OleDbDataReader need to be closed and then re-executed for every control?
Is there a more effecient way of doing this other than using a loop?

Thanks in advance, Steven


Dim spTermType As OleDb.OleDbDataReader
Dim prmTermType As OleDbParameter
Dim cmdTermType As New OleDb.OleDbCommand("sp_web_Search", cnnSearch)
cmdTermType.CommandType = CommandType.StoredProcedure

spTermType = cmdTermType.ExecuteReader()
ddlType1.DataSource = spTermType
ddlType1.DataTextField = "TerminationType_ID"
ddlType1.DataTextField = "TerminationType_ID"
ddlType1.DataBind()

spTermType.Close() : spTermType = Nothing
spTermType = cmdTermType.ExecuteReader()
ddlType2.DataSource = spTermType
ddlType2.DataTextField = "TerminationType_ID"
ddlType2.DataTextField = "TerminationType_ID"
ddlType2.DataBind()
 
M

Manohar Kamath [MVP]

If you think many controls share common data, you could create another
control that just retrieves data and "feeds" it to other controls (say, a
dataset/datatable). But, if your controls are independent, the way you are
doing it is the best way to go.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top