I get this error message in cmd.ExecuteNonQuery()
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '//' at line 1"
when I run the code below. The concept is to read some values from a databse and write the result into another databse if the condition is satisfied.
Dim conString As String
Dim myconn As MySqlConnection
Dim sql As String
conString =
"Server=localhost; Database=xyz; Uid=root"myconn = New MySqlConnection(conString)
sql =
"Select site_id, timestring, pwr_vin, dsp_dig_in_6 from soh_data order by timestring desc limit 1"
Dim mycmd As MySqlCommand = New MySqlCommand(sql, myconn)
myconn.Open()
Dim dr As MySqlDataReader = mycmd.ExecuteReader()
While dr.Read()Response.Write("Site Id: " & dr.GetInt32(0) & "<br/>" & "Date and Time: " & dr.GetDateTime(1) & "<br/>" & "Data Logger Power:" & dr.GetDouble(2) & "<br/>" & "UPS Power Status:" & dr.GetInt32(3))
If dr.GetDouble(2) < 20 Then
Dim id As Int32 = dr.GetInt32(0)
Dim time As DateTime = dr.GetDateTime(1)
Dim dpower As Double = dr.GetDouble(2)Dim upower As Int32 = dr.GetInt32(3)
Dim mycon As MySqlConnection = New MySqlConnection("Server=localhost; Database=neadb; Uid=root")Dim strSQL As String = "Insert into soh_event(site_id,timestring,pwr_vin,dsp_dig_in_6,status)" & _
"values(" & _id & ", " & _
"#" & time & "#" & ", " & dpower & ", " & upower & ", 'Fail')"Dim cmd As MySqlCommand = New MySqlCommand(strSQL, mycon)
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End If
dr.Close()
myconn.Close()
End While
I am clueles about this error. Anybody encountered this kind of problem please help.