DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   SQL UPDATE Error (http://www.daniweb.com/forums/thread83584.html)

ViRiPuFF Jul 15th, 2007 9:39 am
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 & " ' "

sk8ndestroy14 Jul 16th, 2007 2:49 pm
Re: SQL UPDATE Error
 
It looks like you never declared the datatype of loSQL.

ViRiPuFF Jul 16th, 2007 5:48 pm
Re: SQL UPDATE Error
 
Quote:

Originally Posted by sk8ndestroy14 (Post 404475)
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

debasisdas Jul 19th, 2007 8:43 am
Re: SQL UPDATE Error
 
thanx for self learning, that really helps a lot.


All times are GMT -4. The time now is 4:10 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC