Ok so im having trouble with a very stupid and simple thing, inserting date into mysql.
Straight to it, heres my code
The error im getting is
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 '14:04:58)' at line 1
When i look at the commandtext its trying to insert it looks like this
"INSERT INTO tblServerReply(FKServerID, ReplyStatus, ReplyRoundTripTime, ReplyTimeStamp) VALUES (1,0,1,2013-09-10 14:04:58)"
What am i missing here? this should be so simple but its driving me nuts.
Straight to it, heres my code
Code:
Sub insertStatus(ByVal status, ByVal serverid, ByVal replytime)
Dim mytimestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
MysqlConn = New MySqlConnection()
MysqlConn.ConnectionString = "server=;user id=;password=;database="
Dim cmd As New MySqlCommand()
Stop
Try
MysqlConn.Open()
cmd.Connection = MysqlConn
cmd.CommandText = "INSERT INTO tblServerReply(FKServerID, ReplyStatus, ReplyRoundTripTime, ReplyTimeStamp) VALUES (" & serverid & "," & status & "," & replytime & "," & mytimestamp & ")"
cmd.Prepare()
cmd.ExecuteNonQuery()
'MysqlConn.Close()
Catch ex As MySqlException
Console.WriteLine("Error: " & ex.ToString())
End Try
End SubQuote:
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 '14:04:58)' at line 1
Quote:
"INSERT INTO tblServerReply(FKServerID, ReplyStatus, ReplyRoundTripTime, ReplyTimeStamp) VALUES (1,0,1,2013-09-10 14:04:58)"