473,387 Members | 3,820 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,387 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 1471
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.