2 Replies - 315 Views - Last Post: 05 February 2013 - 07:33 PM Rate Topic: -----

#1 Guitora Kuronato  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 28
  • Joined: 02-December 12

Data Type mismatch in criteria

Posted 05 February 2013 - 07:12 PM

hello all, i got error at update code,
while i click update, i got error at data type mismatch incriteria,,
i know the error at
([S/N] = '" & S_NTextBox.Text & "')"
here
but i dont know what i need to fill for the S/N
this is my update code

con = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\notifdb.accdb")
        Dim cmdUpdate As New OleDbCommand
        con.Open()
        cmdUpdate.CommandText = "UPDATE NFTB SET REMARKS = '" & REMARKSTextBox.Text & "', TIME_IN = '" & TIME_INTextBox.Text & "', TIME_OUT = '" & TIME_OUTTextBox.Text & "', CHECKED_IN = '" & CHECKED_INTextBox.Text & "', CHECKED_OUT = '" & CHECKED_OUTTextBox.Text & "', IN_ON = '" & IN_ONTextBox.Text & "', OUT_ON = '" & OUT_ONTextBox.Text & "', APP = '" & APPTextBox.Text & "' WHERE ([S/N] = '" & S_NTextBox.Text & "')"
        cmdUpdate.CommandType = CommandType.Text
        cmdUpdate.Connection = con
        cmdUpdate.ExecuteNonQuery()
        con.Close()
        cmdUpdate.Dispose()


Is This A Good Question/Topic? 1
  • +

Replies To: Data Type mismatch in criteria

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Data Type mismatch in criteria

Posted 05 February 2013 - 07:20 PM

If S/N is an AutoNumber field it is not surrounded by the apostrophes. Try submitting it as
...WHERE ([S/N] = " & S_NTextBox.Text & ")"

Of course the best solution would be to use a parameterized query and that would alleviate a lot of these types of errors.

This post has been edited by CharlieMay: 05 February 2013 - 07:21 PM

Was This Post Helpful? 1
  • +
  • -

#3 Guitora Kuronato  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 28
  • Joined: 02-December 12

Re: Data Type mismatch in criteria

Posted 05 February 2013 - 07:33 PM

Opzz,,
I tried it again.
It's work, thanks a lot..

This post has been edited by Guitora Kuronato: 05 February 2013 - 07:33 PM

Was This Post Helpful? -1
  • +
  • -

Page 1 of 1