I would like to post my SQL results into a textlist in VB.net, I am selecting from 2 fields, UserName & Passwords
My query is:
USE fasttest2008;
SELECT [username],
[password]
FROM users;
I want it to post into tb_user & tb_pass
I have looked at another post on this site and managed to nearly get it, i feel that I am missing just one thing.
I am aware this code only posts the results into one field atm.
Dim sConnString As String = "Data Source=.\scuser;Initial Catalog=master;Integrated Security=True"
Dim sText As String = String.Empty
Using cn As New SqlConnection(sConnString)
cn.Open()
Dim cmd As New SqlClient.SqlCommand("use testdb select [username], [password] from users")
Dim r As SqlDataReader = cmd.ExecuteReader()
If Not r.HasRows Then Exit Sub
Do While r.Read()
sText = sText & ";" & r.GetString(0)
Loop
cn.Close()
End Using
lb_user.Text = sText
sText = r.GetString(0) & " - " & r.GetString(1)Passwords should not be stored as plaintext