Results 1 to 2 of 2

Thread: whats the error in this code ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    23

    Unhappy 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

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    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
  •  



Click Here to Expand Forum to Full Width