Hi,
Here is a simple datareader example.
Dim strConn As String
Dim conn As SqlConnection
Dim drCustomer As SqlDataReader
Dim cmd As SqlCommand
strConn = "Server = " + Environment.MachineName + "\VSdotNet;"
strConn += "Database = NorthWind;"
strConn += "Integrated Security = SSPI;"
conn = New SqlConnection(strConn)
cmd = New SqlCommand("Select Customers.*, (Customers.ContactTitle + ', ' +
Customers.ContactName) as FullName from Customers Order by ContactTitle,
ContactName", conn)
conn.Open()
drCustomer = cmd.ExecuteReader
Do While drCustomer.Read
ComboBox1.Items.Add(drCustomer("FullName"))
Loop
conn.Close()
Ken
---------------
"SQL" <no*****@adfadfd.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
I'm new at this, so please forgive me if my question has a simple answer
to
it.
I'm trying to get a value out of a SqlDataReader. Here is my code to do
so:
Dim mySQLCommand As New SqlCommand("SELECT NextPrbKey FROM SystemAdmin",
cn)
Dim mySQLReader As SqlDataReader = mySQLCommand.ExecuteReader()
intGetNextKey = mySQLReader.GetValue(0)
This does not return a value. I thought that GetValue(0) would return the
value of column 0 in my result set. What am I doing wrong?
Thanks.