|
-
Jun 16th, 2004, 06:46 PM
#1
Thread Starter
Member
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
-
Jun 16th, 2004, 09:17 PM
#2
Re: Two Database Fields in One Listbox
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
-
Jun 17th, 2004, 05:02 AM
#3
PowerPoster
Hi,
I find the best way is to load the database fields into an arraylist. You can then easily put them in what order you wish in the listbox.
Last edited by taxes; Jun 17th, 2004 at 06:16 AM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|