Two Database Fields in One Listbox
I'm stuck on this one, so I'm on my knees begging for help.
I have two fields in a database, LastName and FirstName. I want to fill a listbox so that each row in the database appears like this:
-------------------------------
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
------------------------------
I can get it to work fine with one or the other as the text field, but how do you show two text fields?
HWOODKY
Re: Two Database Fields in One Listbox
Quote:
Originally posted by HollywoodKY
I'm stuck on this one, so I'm on my knees begging for help.
I have two fields in a database, LastName and FirstName. I want to fill a listbox so that each row in the database appears like this:
-------------------------------
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
| LastName, FirstName |
------------------------------
I can get it to work fine with one or the other as the text field, but how do you show two text fields?
HWOODKY
like this..if not sorry
VB Code:
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.Open()
cm.Connection = cn
cm.CommandType = CommandType.StoredProcedure
getd()
End Sub
Sub getd()
Try
With cm
.Parameters.Clear()
.CommandText = "retrievecustomer"
Dim r As SqlDataReader = .ExecuteReader
While r.Read
Dim s As String = r.GetValue(0)
Dim x As String = " , " & r.GetValue(1)
Dim f As String = s & x
ListBox1.Items.Add(f)
End While
r.Close()
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub