473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Combobox empty

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

Nov 22 '05 #1
3 1470
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" <an*******@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
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

Nov 22 '05 #2
Hi william

How do i find out what framework i have

thx
Nov 22 '05 #3
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
Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oren Kaplan | last post by:
Hello, I posted a msg on the Access-related groups in hope someone there could help me but since almost two days have past and I didnt get a response (Im a bit hard pressed with the problem) I...
2
by: Jac | last post by:
Hey, How can I set the display value of a combobox empty? But all the posible choices are available when I push the trianglebut. Sometimes if I set the selecteditem = null it works, other...
2
by: pmcguire | last post by:
I have derived a ComboBoxColumnStyle that inherits DataGridColumnStyle. It works fine except for one behavior. If the user selects a new value from the ComboBox's pulldown list on a brand new...
0
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
1
by: fiaolle | last post by:
Hi The first set of source code is the class for a combobox in a grid, hopefully. In the second set of code we try to use the combobox class, but the grid is empty. I don't understand how this...
3
by: samoore33 | last post by:
I am populating a ComboBox at run time. I insert the first value of "Choose Value" cboTaxValue.Item.Insert(0, "Choose Value") Then I loop through the rest of the values to be added to the...
1
by: SM | last post by:
Hello, Im creating a combobox using the Javascript and the DOM. If the combobox exists, i don't want to create another one. I want to empty all the values and put new values. I was able to...
3
by: Koliber (js) | last post by:
how to put a text value in edit field of combobox when this text value is none of contained if combobox or how to change selected by click text value from combobox without removing it and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.