visual basic data type mismatch in criteria expression??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chili007
    New Member
    • Dec 2011
    • 3

    visual basic data type mismatch in criteria expression??

    i cant find the problem can anyone help me pls???


    If userNameTextBox .Text <> "" Then
    Dim sqlQRY As String = "INSERT INTO SalesOrder Values ('" & salesNoTextBox. Text & "', '" & orderDateTextBo x.Text & "', '" & userNameTextBox .Text & "', '" & productCodeText Box.Text & "', '" & quantityTextBox .Text & "')"
    Try
    conn.Open()
    Dim cmd As OleDbCommand = New OleDbCommand(sq lQRY, conn)
    cmd.ExecuteNonQ uery()
    Catch ex As OleDbException
    MsgBox("Error: " & ex.ToString & vbCrLf)
    Finally
    conn.Close()
    End Try
    saveButton.Enab led = False
    Else
    MsgBox("Please select customer")
    userNameTextBox .Focus()
    End If
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It's probably because you're trying to insert a string into that date field. But I have no idea because you haven't told us what the data types are for your fields.

    Comment

    • chili007
      New Member
      • Dec 2011
      • 3

      #3
      i am doing a sales order form. pls help!!!

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I did help. I helped all I could given the information that was provided.

        Comment

        • chili007
          New Member
          • Dec 2011
          • 3

          #5
          so may i know which code i have to change?

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            I don't know what you have to change. I can only guess at the error because I don't have everything I need to know to pinpoint the error.

            Comment

            • nirgunpratik
              New Member
              • Dec 2011
              • 4

              #7
              Try this and let me know if it works.....

              "INSERT INTO SalesOrder Values ('" & salesNoTextBox. Text & "', '" & Convert.ToDateT ime(orderDateTe xtBox.Text) & "', '" & userNameTextBox .Text & "', '" & productCodeText Box.Text & "', '" & quantityTextBox .Text & "')"

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                I wonder whether putting hashes (#) around the date value might help.

                But yeah, what we really need is more info about the circumstances.

                Comment

                Working...