hi every one i am trying to create shopping cart working with VB & access when i wrote add function an error occur i do not know how to solve"Syntax error in INSERT INTO statment" it please help me to solve the problem
a shot screen is attached contain page and exeption msg here is the function
Protected Sub getproduct_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles getproduct.Click
Dim x As String
x = Session("user")
Dim LongTimeString As String = ""
Dim DateToString As String = ""
Dim ShortTimeString As String = ""
Dim LongDateString As String = ""
Dim Daysinmonth As Integer = 0
Dim ErrorStr As String = ""
Dim ErrorStr1 As String = ""
con = New OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand
Dim Add As String
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\USER\Desktop\my\WebSite2\App_Data\EC.mdb';Persist Security Info=True"
If con.State = Data.ConnectionState.Closed Then
con.Open()
End If
Dim OrderDate = System.DateTime.Now
LongTimeString = OrderDate.ToLongTimeString
Daysinmonth = System.DateTime.DaysInMonth(OrderDate.Year, OrderDate.Month)
DateToString = OrderDate.ToString
ShortTimeString = OrderDate.ToShortTimeString
LongDateString = OrderDate.ToLongDateString
If (product.Text = "") Then
ErrorStr = ErrorStr & " Please Enter Product number, "
End If
If (Quantity.Text = "") Then
ErrorStr1 = ErrorStr1 & " Please Enter Product quantity, "
End If
Dim pri = "SELECT price FROM product WHERE ProductNO='" & product.Text & "'"
cmd.Connection = con
cmd.CommandText = pri
Dim s As String = cmd.ExecuteScalar()
Add = "INSERT INTO order Values ('" & 1 & "','" & Quantity.Text & "','" & pri & "','" & Daysinmonth & "','" & x & "','" & product.Text & "');"
cmd.CommandText = Add
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub