title: Syntax Error! >_<
body: <p>Guy's Cant seem to find my error in VB.Net ! my codes are all right ! but the function still won't save on the database cause of Syntax error in my Insert into statement ! Please help me ! :D!</p>
  
  <p>This is my Code!:D!</p>
  
  <pre><code>Dim Transaction As OleDb.OleDbTransaction = Nothing
  Dim Connection As OleDb.OleDbConnection = Nothing
  Try
  
      Connection = New OleDb.OleDbConnection(My.Settings.POS_CanteenConnectionString)
      Connection.Open()
      Transaction = Connection.BeginTransaction
      Dim SQL As String = "Insert into Recipt (ReciptDate,ReciptTotal)Values(:0,:1)"
      Dim CMD1 As New OleDb.OleDbCommand
      CMD1.Connection = Connection
      CMD1.Transaction = Transaction
      CMD1.CommandText = SQL
      CMD1.Parameters.AddWithValue(":0", Now.Date)
      CMD1.Parameters.AddWithValue(":1", TextBox4.Text)
      CMD1.ExecuteNonQuery()
      CMD1.Dispose()
      SQL = "Select Max(ReciptID) As MAXID from Recipt"
      Dim CMD2 As New OleDb.OleDbCommand
      CMD2.Connection = Connection
      CMD2.Transaction = Transaction
      CMD2.CommandText = SQL
      Dim ReciptID As Long = CMD2.ExecuteScalar()
      CMD2.Dispose()
      Dim I As Integer
      For I = 0 To DGV3.Rows.Count - 1
          Dim BarCode As String = DGV3.Rows(I).Cells(0).Value
          Dim BuyPrice As Decimal = DGV3.Rows(I).Cells(2).Value
          Dim SellPrice As Decimal = DGV3.Rows(I).Cells(3).Value
          Dim ItemCount As Integer = DGV3.Rows(I).Cells(4).Value
          Dim CMD3 As New OleDb.OleDbCommand
          SQL = "Insert to ReciptDetails" &amp; _
                "(ReciptID,BarCode,ItemCount,ItemBuyPrice,ItemSellPrice)" &amp; _
                "Values" &amp; _
                "(:0          ,:1           ,:2          ,:3          ,:4          )"
          CMD3.Connection = Connection
          CMD3.Transaction = Transaction
          CMD3.CommandText = SQL
          CMD3.Parameters.AddWithValue(":0", ReciptID)
          CMD3.Parameters.AddWithValue(":1", BarCode)
          CMD3.Parameters.AddWithValue(":2", BuyPrice)
          CMD3.Parameters.AddWithValue(":3", ItemCount)
          CMD3.Parameters.AddWithValue(":4", SellPrice)
  
          CMD3.ExecuteNonQuery()
          CMD3.Dispose()
  
      Next
      Transaction.Commit()
  
      Transaction.Dispose()
      Connection.Close()
      Connection.Dispose()
      DGV3.Rows.Clear()
      TextBox4.Text = ""
  Catch ex As Exception
  
      If Transaction IsNot Nothing Then
          Transaction.Rollback()
      End If
      If Connection IsNot Nothing Then
          If Connection.State = ConnectionState.Open Then
              Connection.Close()
          End If
  
      End If
      MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "ERROR")
  
  End Try
  </code></pre>