Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 [RESOLVED] Insert date into mysql

$
0
0
Ok so im having trouble with a very stupid and simple thing, inserting date into mysql.

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 Sub

The error im getting is

Quote:

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

Quote:

"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.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>