943,876 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1746
  • VB.NET RSS
Jul 15th, 2007
0

SQL UPDATE Error

Expand Post »
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 Syntax (Toggle Plain Text)
  1.  
  2. Dim IntSid As String
  3. Dim Sid As String
  4. Dim I As Integer
  5.  
  6. IntSid = Me.TTIn.Text
  7. Sid = Me.SessionIDTextBox.Text
  8. I = CInt(Val(Sid))
  9.  
  10.  
  11. Dim loSQL = "UPDATE tblSession SET TTout = '" & _
  12. IntSid & "' WHERE SessionId = '" & _
  13. I & " ' "
Similar Threads
Reputation Points: 16
Solved Threads: 0
Light Poster
ViRiPuFF is offline Offline
32 posts
since Jun 2007
Jul 16th, 2007
0

Re: SQL UPDATE Error

It looks like you never declared the datatype of loSQL.
Reputation Points: 437
Solved Threads: 1
Posting Virtuoso
sk8ndestroy14 is offline Offline
1,851 posts
since Mar 2007
Jul 16th, 2007
0

Re: SQL UPDATE Error

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

VB.NET Syntax (Toggle Plain Text)
  1. Dim loSQL = "UPDATE tblSession SET TTout = '" & _
  2. IntSid & "' WHERE SessionId = '" & _
  3. I & " ' "

This should have been


VB.NET Syntax (Toggle Plain Text)
  1. Dim loSQL = "UPDATE tblSession SET TTout = '" & _
  2. Me.TTIn.Text & "'WHERE SessionId = " & _
  3. I & " "

ViRi
Reputation Points: 16
Solved Threads: 0
Light Poster
ViRiPuFF is offline Offline
32 posts
since Jun 2007
Jul 19th, 2007
1

Re: SQL UPDATE Error

thanx for self learning, that really helps a lot.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: load data from access database into form
Next Thread in VB.NET Forum Timeline: Doubt





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC