SQL UPDATE error

ViRi

Member
Joined
Jun 19, 2007
Messages
8
Programming Experience
3-5
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.

VB.NET:
        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 & " ' "

ViRi
 
u are updating something that does not match the datatype of ur database
 
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
VB.NET:
Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        IntSid & "' WHERE SessionId = '" & _
        I & " ' "

This should have been

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

ViRi
 
Take a read of the PQ link in my signature, followed by the DW2 link, (section on creating a simple data app) for a better/simpler/safer way of doing data access than your current method
 
I appreciate that the way you mention is probably better/simpler/safer way of doing data access than my current method.

The problem is that I now have 99% of this project ready and don't really have that much time to spare at the moment.

I read as you suggested the Data Access Walkthroughs and carried out the exercises you mentioned. I spent a day trying to figure out how get the same results with the new way, but to tell you the truth I did not get very far very quickly, so I opted to use the old way that now works perfectly well as I had to present this software today

ViRi
 
Back
Top