|
-
Mar 27th, 2004, 10:48 PM
#1
Thread Starter
Junior Member
whats the error in this code ?
DBConn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& strPath)
dbCommand.CommandText = "Update Subject Set " _
& "subName='" & strSN & "', " _
& "subPreCode='" & strPC & "', " _
& "subPreName='" & strPN & "', " _
& "subSemester1='" & strS1 & "', " _
& "subSemester2='" & strS2 & "', " _
& "subSemester3='" & strS3 & "', " _
& "creditPoints='" & strCP & "', " _
& "courseCode='" & strCC & "', " _
& "WHERE subCode=" & Str & cbSubId.Text & Str
NOTE : replace Str by single inverted commas (')
wats the error in this code, when executing i get error in update statement ?
plz help
-
Mar 28th, 2004, 12:17 AM
#2
Frenzied Member
If it is a string (text) value in the database, surround it with (') single quotes.
If it is a number, then don't.
If subCode is a string
Code:
WHERE subCode = '" & cbSubId.Text & "'"
If subCode is a number
Code:
WHERE subCode = " & cbSubId.Text
Or
WHERE subCode = " & Integer.Parse(cbSubId.Text)
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|