ExecuteNonQuery Wierdness



The following code runs and gets no errors...the select returns no
rows, what am I doing wrong? I instantiate the class, run the write a
few teams, then the read, and in vb.net I still see no data in the log
table.

Public Class cLog

Enum eventType As Integer
Ph = 1
Temperature = 2
ORP = 3
Timer = 4
Misc = 5
End Enum

Private dbConn As SqlClient.SqlConnection
Private dbCommand As SqlClient.SqlCommand

Public Sub New()

dbConn = New
SqlClient.SqlConnection(My.Settings.DBConnectionString)
dbConn.Open()

End Sub

Public Sub Write(ByVal sensor As Integer, ByVal eventId As Integer,
ByVal eventValue As String)
Dim sql As String

sql = "insert into Log (sensor, eventID, eventValue) values ("
& sensor & "," & eventId & ",'" & eventValue & "')"

dbCommand = dbConn.CreateCommand()
dbCommand.CommandText = sql
dbCommand.ExecuteNonQuery()

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

End Class

.



Relevant Pages

  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Import Access records to excel (parameter is a called funct)
    ... It querys alright but does not roll back ... > Dim SQL As String ...
    (microsoft.public.excel.programming)
  • RE: Passing Criteria to SQL Statement
    ... Public Sub RunEmailDist ... And Change the SQL to ... Public Sub RunEmailDist(MySAMMS as string) ... > Dim MyRecs As Object ...
    (microsoft.public.access.modulesdaovba)
  • Re: Form/Subform
    ... Private Sub Fullname_NotInList(NewData As String, ... Dim sql As String ... Dim strNames() As String ... DoCmd.RunSQL sql, False ...
    (comp.databases.ms-access)