Combobox empty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am using a datareader to retrieve values from my database and fill a combobox. Can anyone tell me how i would display a message in the combobox if no results are returned. At the moment i just get a blank combobox which may be confusing to the user

Many th
 
If you are using the 1.1 framework

if(dr.HasRows){
combobox.Items.Add(dr.Getxxx());

}
else{combobox.Items.Add("No Records Here");}

If you aren't, you can set a flag which is set to false and gets set to true
within the dr.Read()...it's it's false when you get out of the loop, Add
some other text to indicate that there's nothing there.
Massy said:
Hi,

I am using a datareader to retrieve values from my database and fill a
combobox. Can anyone tell me how i would display a message in the combobox
if no results are returned. At the moment i just get a blank combobox which
may be confusing to the user.
 
Hello William

This is what i have tried? I am getting a message stating that
'HasRows' is not a member of 'System.Data.SqlClient.SQLDataReader'.
The following code is underlined with the problem
(Myreader.HasRows

here is my full code...


Tr
Cn.Open(
Dim Myreader As SqlDataReade
Myreader = Mycmd.ExecuteReader(
While Myreader.Rea
If (Myreader.HasRows) The
CBox1.Items.Add(Myreader.GetSqlString(0)
Else : CBox1.Items.Add("No Records Here"
End I
End Whil
Catch ex As Exceptio
MsgBox(ex.Message
Finall
Cn.Close(
End Tr

Do u know what im doin wrong
Many thx
 
Back
Top