Hey,
I'm currently using Visual Basic 2005, MS Access 2003 and OleDb Connection.
This is my database module i use:
This is the code i am trying to execute.Code:Module Database Public Connection As New OleDb.OleDbConnection Public ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database.mdb" Public Command As OleDb.OleDbCommand Public Reader As OleDb.OleDbDataReader End Module
The Error is: Data type mismatch in criteria expression.Code:Dim i Dim Customer As String Dim items As String Dim price As Double Command = Connection.CreateCommand For i = 0 To Checkoutbox.Items.Count - 1 Customer = Customerlist.SelectedItem.ToString items = items + "and " + Checkoutbox.Items.Item(i).text price = price + Checkoutbox.Items.Item(i).SubItems(1).Text() Command.CommandText = "INSERT INTO Transactions VALUES ('" & "" & "','" & Customer & "','" & items & "','" & price & "','" & System.DateTime.Today & "');" Next Command.ExecuteNonQuery()
The first field in my database is an autonumber field.
When inserting data into the table i want the autonumber field to just fill itself in. I don't know what to put into the database statement.
The Fields for the database are:Code:Command.CommandText = "INSERT INTO Transactions VALUES ('" & "" & "','" & Customer & "','" & items & "','" & price & "','" & System.DateTime.Today & "');"
Transaction_ID: Data Type: Autonumber - Primary Key
Transaction_Customer: Data Type: Text
Transaction_Items: Data Type: Text
Transaction_Price: Data Type: Currency
Transaction_Date: Data Type: Date/Time
Hope that makes sense.




Reply With Quote