DataBind() Count or EOF

S

Steven K

Hello,

I am filling a DropDownList (DropDownList1) with data from a stored
procedure. Is there an equivalent of the RecordSet.EOF to determine if
there are any records using DataBind?

Dim spDropDownList As OleDb.OleDbDataReader
Dim cmdDDL As New OleDb.OleDbCommand("sp_Search", cnnSearch)
spDropDownList = cmdDDL.ExecuteReader()
DropDownList1.DataSource = spDropDownList
DropDownList1.DataTextField = "BusinessProduct"
DropDownList1.DataTextField = "BusinessProduct"
DropDownList1.DataBind()
spDropDownList.Close() : spDropDownList = Nothing
 
S

Steven K

Thank you, but I think I figured it out using "HasRows":

Dim Public blnHasRow as Boolean
blnHasRow = spDropDownList.HasRows
If spDropDownList.HasRows = True Then Response.Write(blnHasRow)
 
M

mikeb

Steven said:
Hello,

I am filling a DropDownList (DropDownList1) with data from a stored
procedure. Is there an equivalent of the RecordSet.EOF to determine if
there are any records using DataBind?

Dim spDropDownList As OleDb.OleDbDataReader
Dim cmdDDL As New OleDb.OleDbCommand("sp_Search", cnnSearch)
spDropDownList = cmdDDL.ExecuteReader()
DropDownList1.DataSource = spDropDownList
DropDownList1.DataTextField = "BusinessProduct"
DropDownList1.DataTextField = "BusinessProduct"
DropDownList1.DataBind()
spDropDownList.Close() : spDropDownList = Nothing

Would DropDownList1.Items.Count do what you need?

In 1.1 of the framework, you could use spDropDownList.HasRows if you
need to know before the databind operation.
 
A

Abhijeet Dev

You can use HasRows method of OleDbDataReader. But that comes only with .NET
framework 1.1. There is another logical work around but i dont think its
required at all.

Abhijeet Dev
 

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

Top