954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

SQL UPDATE Error

Hi

I have the following code which generates an error 'Data Type mismatch in criteria expression'

The purpose of the code is to write a value to a database at a specific row.

Dim IntSid As String
        Dim Sid As String
        Dim I As Integer
        
        IntSid = Me.TTIn.Text
        Sid = Me.SessionIDTextBox.Text
        I = CInt(Val(Sid))


        Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        IntSid & "' WHERE SessionId = '" & _
        I & " ' "
ViRiPuFF
Light Poster
32 posts since Jun 2007
Reputation Points: 16
Solved Threads: 0
 

It looks like you never declared the datatype of loSQL.

sk8ndestroy14
Posting Virtuoso
1,852 posts since Mar 2007
Reputation Points: 437
Solved Threads: 1
 
It looks like you never declared the datatype of loSQL.


Hi

I got it to work the problem was the single quote around the variable I which is an Integer and not a String

My original SQL statement was

Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        IntSid & "' WHERE SessionId = '" & _
        I & " ' "


This should have been

Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        Me.TTIn.Text & "'WHERE SessionId = " & _
        I & " "


ViRi

ViRiPuFF
Light Poster
32 posts since Jun 2007
Reputation Points: 16
Solved Threads: 0
 

thanx for self learning, that really helps a lot.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You