Results 1 to 9 of 9

Thread: [RESOLVED]MS Access 2003+VB.Net 2005+Data type mismatch

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    63

    Resolved [RESOLVED]MS Access 2003+VB.Net 2005+Data type mismatch

    Hey,

    I'm currently using Visual Basic 2005, MS Access 2003 and OleDb Connection.
    This is my database module i use:

    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
    This is the code i am trying to execute.

    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 Error is: Data type mismatch in criteria expression.

    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.

    Code:
    Command.CommandText = "INSERT INTO Transactions VALUES ('" & "" & "','" & Customer & "','" & items & "','" & price & "','" & System.DateTime.Today & "');"
    The Fields for the database are:
    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.
    Last edited by Wulfgur; Jan 5th, 2008 at 04:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width