473,386 Members | 1,819 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.

Listbox Binding

OuTCasT
374 256MB
Hi
I have filled a listbox with a column of information from my sql database

Expand|Select|Wrap|Line Numbers
  1. Private Sub GetClients()
  2.         Dim sqlCom As SqlCommand = New SqlCommand("select emailaddress from register where paymentreceived = 'No'", sqlCon)
  3.         sqlCon.Open()
  4.         sqlAdapter = New SqlDataAdapter(sqlCom)
  5.         sqlAdapter.Fill(sqlDS, "register")
  6.  
  7.  
  8.         dr = sqlCom.ExecuteReader
  9.  
  10.         If dr.HasRows Then
  11.             For Each rec As Common.DbDataRecord In dr
  12.                 alRows.Add(rec)
  13.             Next
  14.             ListBox1.DataSource = alRows
  15.             ListBox1.DisplayMember = "emailaddress"
  16.  
  17.         End If
  18.         sqlCon.Close()
  19.     End Sub
But now when i try to loop through the rows of the listbox

Expand|Select|Wrap|Line Numbers
  1.  Dim i As Integer
  2.         For i = 0 To ListBox1.Items.Count - 1
  3.             MsgBox(ListBox1.Items(i))
  4.         Next
i get an error

conversion from type 'DataRecordInternal' to type 'String' is not valid

is there a better way to get the values... ?
Jul 9 '09 #1
1 2269
OuTCasT
374 256MB
Corrected the error.
Expand|Select|Wrap|Line Numbers
  1. For Each row In sqlTable.Rows
  2.              row("emailAddress")
  3. Next
Jul 9 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jason | last post by:
Here is an odd issue. I am trying to shed some light on why this is causing a problem. I have an ArrayList. I am binding it to a ListBox control with has its Sort property set to True. If the...
1
by: Noah Coad [MVP & MCP] | last post by:
I have a ListBox that is bound to an array of 'Client' objects with a 'Name' property (DisplayMember). The 'Name' property is changed, but the ListBox does not update to reflect these changes ...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
6
by: Niggy | last post by:
Hi there, I would like to display the values of the index as chosen by the user in a listbox. These values would be as per the datavaluefield. On testing I get a value of -1: Private Sub...
7
by: amber | last post by:
Hello, I have a form with a listbox that displays a list of records from a SQL table. When one of these is selected, another listbox is populated with data from a SQL table that is linked to the 1st...
1
by: Hoffmania | last post by:
Hello, I am binding a DataSet to a listbox. This listbox is used to set the current binding for an appointment page. A problem I have is that there can only be one appointment per day and I...
1
by: A. Spiehler | last post by:
I'm trying to fill a listBox control with string members from an array of objects. I think using data binding is supposed to be the easiest way to do this. I've never used data binding before and...
1
by: pauled | last post by:
Hello all, Framework 1.1 VS 2003 Binding listbox. I have an array of objects that I am trying to use as the datasource for a listbox. The array is returned from a webservice and seems to be...
2
by: Randy | last post by:
I have two listboxes on a form. The first box displays categories while the second box displays the items belonging to the category selected in the first box. Thus, the second box is essentially...
3
by: Angel Blue01 | last post by:
I have a form with a binding navigator that draws from a database via drag-and-drop-created controls. I'm filling a listbox with the results of a query. The listbox contains data related to the...
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: 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: 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
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?
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
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,...

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.