PC Review


Reply
Thread Tools Rate Thread

Combobox empty

 
 
=?Utf-8?B?TWFzc3k=?=
Guest
Posts: n/a
 
      20th Feb 2004
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

 
Reply With Quote
 
 
 
 
William Ryan eMVP
Guest
Posts: n/a
 
      21st Feb 2004
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" <(E-Mail Removed)> wrote in message
news:7D481807-CA37-4389-B660-(E-Mail Removed)...
> 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 thx
>



 
Reply With Quote
 
=?Utf-8?B?TWFzc3k=?=
Guest
Posts: n/a
 
      21st Feb 2004
Hi william

How do i find out what framework i have

thx
 
Reply With Quote
 
=?Utf-8?B?TWFzc3k=?=
Guest
Posts: n/a
 
      21st Feb 2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
combobox empty mcnewsxp Microsoft Access Getting Started 1 8th Oct 2008 12:47 AM
ComboBox should be empty for new records andi Microsoft Access 2 26th Oct 2007 08:22 PM
combobox.SelectedIndex = -1 does not empty combobox =?Utf-8?B?d2VzYmlyZA==?= Microsoft Dot NET Framework Forms 1 24th Mar 2006 02:56 PM
ComboBox stays empty Marco Alting Microsoft Access Forms 1 21st Jan 2004 12:32 PM
Combobox is empty Koos Koets Microsoft Access Getting Started 2 5th Sep 2003 12:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 AM.