this the the code for inserting data in a database

Dim cn As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("database.mdb"))
        cn.Open()
        Dim cmdr As New Data.OleDb.OleDbCommand
        cmdr.CommandText = "SELECT [Customer_ID] FROM [Customers] WHERE FirstName LIKE '" & User.Identity.Name & "'"
        Dim id As Integer
        cmdr.Connection = cn
        
        id = System.Convert.ToInt32(cmdr.ExecuteScalar())
        Dim cmd As Data.OleDb.OleDbCommand = New Data.OleDb.OleDbCommand
        Dim SQLTxt As String = "INSERT INTO Orders (Customer_ID,Total_price,Delivery,Ordered time)VALUES( '" & id & "','" & lblTotal.Text & "','" & CheckBox1.Checked & "','" & DateTime.Now() & "')"
       
        

        cmd.Connection = cn
        cmd.CommandText = SQLTxt
        cmd.ExecuteNonQuery()
        cmd.Connection.Close()

the error
Syntax error in INSERT INTO statement.


Line 106: cmd.Connection = cn
Line 107: cmd.CommandText = SQLTxt
Line 108: cmd.ExecuteNonQuery()
Line 109: cmd.Connection.Close()


:-/

I think you need Ordered Time in Brackets like this [Ordered Time]

If this solves the issue, please mark this thead as solved and give me some reputation points. Thanks!

I think you need Ordered Time in Brackets like this [Ordered Time]

If this solves the issue, please mark this thead as solved and give me some reputation points. Thanks!

same problem :(

Ok, 2 questions...

First, is the error happening @ the insert or @ the select statement?

Second, when it crashes, can you paste what the value of SQLTxt is... like click on it and it should show you... Thanks.

This article has been dead for over six months. Start a new discussion instead.