G
Guest
Hi all,
I posted this question here before, but I'm still having a problem with this
code.
From my windows form, I opened a connection to a SQL database. I need to
generate a combo box in my form from a SELECT statement that selects the last
name column
from an SQL table. I wrote the following code to do that, but when I run
this code it doesn't do anything!! It doesn't even return an error message to
let me know what's going on!!
All I need is generating this combo box from this table's column in SQL. I
am new to .net. Please help
This is the code I used:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ConnectSQL.Click
Dim SQLEV As SqlClient.SqlConnection = New SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand
Dim ClientName As SqlClient.SqlDataReader
SQLEV.ConnectionString = "Persist Security Info=true;Integrated
Security=false;User ID=sa;Password=xxxx;database=yyy;server=zzzz"
cmd = New SqlClient.SqlCommand("SELECT * FROM qmf_cint", SQLEV)
SQLEV.Open()
ClientName = cmd.ExecuteReader
cbo_ChildName.Items.Clear()
Do While ClientName.Read
cbo_ChildName.Items.Add(ClientName.Item("Last_Name").ToString)
Loop
SQLEV.Close()
I posted this question here before, but I'm still having a problem with this
code.
From my windows form, I opened a connection to a SQL database. I need to
generate a combo box in my form from a SELECT statement that selects the last
name column
from an SQL table. I wrote the following code to do that, but when I run
this code it doesn't do anything!! It doesn't even return an error message to
let me know what's going on!!
All I need is generating this combo box from this table's column in SQL. I
am new to .net. Please help
This is the code I used:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ConnectSQL.Click
Dim SQLEV As SqlClient.SqlConnection = New SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand
Dim ClientName As SqlClient.SqlDataReader
SQLEV.ConnectionString = "Persist Security Info=true;Integrated
Security=false;User ID=sa;Password=xxxx;database=yyy;server=zzzz"
cmd = New SqlClient.SqlCommand("SELECT * FROM qmf_cint", SQLEV)
SQLEV.Open()
ClientName = cmd.ExecuteReader
cbo_ChildName.Items.Clear()
Do While ClientName.Read
cbo_ChildName.Items.Add(ClientName.Item("Last_Name").ToString)
Loop
SQLEV.Close()