Re: ExecuteNonQuery Wierdness
- From: GhostInAK <ghostinak@xxxxxxxxx>
- Date: Fri, 9 Jun 2006 00:38:30 +0000 (UTC)
Hello bug0926@xxxxxxxxx,
The last part of your code is a lil screwy. Try this:
Public Sub Read()
Dim tSQL As String = "SELECT timestamp, sensor, eventId, eventValue FROM Log"
Dim tConnection As SqlConnection = New SqlConnection
Dim tCommand As SqlCommand = New SqlCommand
Dim tReader As SqlDataReader = Nothing
With tCommand
.Connection = tConnection
.COmmandType = CommandType.Text
.CommandText = tSQL
End With
tConnection.Open
tReader = tCommand.ExecuteReader
If tReader.HasRows Then
While tReader.Read
Debug.Print(String.Format("{0}, {1}, {2}, {3}", tReader("timestamp"), tReader("sensor"), tReader("eventId"), tReader("eventValue")))
End While
End If
tConnection.Close
End Sub
Public Sub read()
Dim sql As String
Dim dbReader As SqlClient.SqlDataReader
sql = "select timestamp, sensor, eventId, eventValue from Log"
dbCommand = dbConn.CreateCommand()
dbCommand.CommandText = sql
dbReader = dbCommand.ExecuteReader(sql)
While dbReader.HasRows
Debug.Print(dbReader(0))
Debug.Print(dbReader(1))
End While
dbReader.Close()
End Sub
.
- References:
- ExecuteNonQuery Wierdness
- From: bug0926
- ExecuteNonQuery Wierdness
- Prev by Date: Re: stupid questions re: DatagridView
- Next by Date: Re: Cloning a RichTextBox
- Previous by thread: RE: ExecuteNonQuery Wierdness
- Next by thread: Changing text in Report viewer
- Index(es):
Relevant Pages
|