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.Mac hineName + "\VSdotNet; "
strConn += "Database = NorthWind;"
strConn += "Integrated Security = SSPI;"
conn = New SqlConnection(s trConn)
cmd = New SqlCommand("Sel ect Customers.*, (Customers.Cont actTitle + ', ' +
Customers.Conta ctName) as FullName from Customers Order by ContactTitle,
ContactName", conn)
conn.Open()
drCustomer = cmd.ExecuteRead er
Do While drCustomer.Read
ComboBox1.Items .Add(drCustomer ("FullName") )
Loop
conn.Close()
Ken
---------------
"SQL" <no*****@adfadf d.com> wrote in message
news:OY******** ******@TK2MSFTN GP09.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("SEL ECT NextPrbKey FROM SystemAdmin",
cn)
Dim mySQLReader As SqlDataReader = mySQLCommand.Ex ecuteReader()
intGetNextKey = mySQLReader.Get Value(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.