| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
VB.NET list all the data from DB
|
Original Message
|
Name: charles_cp
Date: July 29, 2005 at 07:58:02 Pacific
Subject: VB.NET list all the data from DBOS: Windows XPCPU/Ram: P4 2.8G/1G |
Comment: Dear, I would like to list all of the email address in the TextBox1 from the DB. But the following program just show the first row of the data ("tony@aol.com"). How to make the TextBox1 showing like that "tony@aol.com, peter@hotmail.com, judy@yahoo.com" ? Please help! My code: -------- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Oledb1 As New OleDbConnection Oledb1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\cus.mdb" Oledb1.Open() If Oledb1.State.Open Then Dim Cmd1 As New OleDbCommand Cmd1.Connection = Oledb1 Cmd1.CommandText = "Select email&', ' From customer" TextBox1.Text = Cmd1.ExecuteScalar() Oledb1.Close() End If End Sub End Class
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: SN
Date: July 30, 2005 at 19:31:24 Pacific
|
Reply: (edit)You need to loop through each record that's returned and get the e-mails individually. Dim emails As String Dim reader as OleDBDataReader reader = cmd1.ExecuteReader() while (reader.Read()) emails &= reader.GetString(0) & "," end While TextBox1.Text = emails Good luck, -SN
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Programming Forum Home