SQL UPDATE cant use characters for update the table column?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lazzypink
    New Member
    • Mar 2008
    • 15

    SQL UPDATE cant use characters for update the table column?

    query = "UPDATE Camera SET CameraName=" + CameraName + " WHERE CameraName=" + oldIPCamera.Cam eraName;

    hi guys! can help me solve this problem? why i cant update the new camera name (camera_3) for replace the old camera name (camera_7)? there is an error "invalid column name camera_7" or is there have any others method to do this? thanks!
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by lazzypink
    query = "UPDATE Camera SET CameraName=" + CameraName + " WHERE CameraName=" + oldIPCamera.Cam eraName;

    hi guys! can help me solve this problem? why i cant update the new camera name (camera_3) for replace the old camera name (camera_7)? there is an error "invalid column name camera_7" or is there have any others method to do this? thanks!
    What is this value oldIPCamera.Cam eraName?
    Is it a column from a table oldIPCamera or its a variable createed in your source code??

    Comment

    • lazzypink
      New Member
      • Mar 2008
      • 15

      #3
      Originally posted by amitpatel66
      What is this value oldIPCamera.Cam eraName?
      Is it a column from a table oldIPCamera or its a variable createed in your source code??
      oldIPCamera.Cam eraName is a variable created in my source code. do u have any idea?...thanks!

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        Originally posted by lazzypink
        oldIPCamera.Cam eraName is a variable created in my source code. do u have any idea?...thanks!
        The problem in your update statement is that you are not enclosing the values camera_7 and the other one in a single quotes. Try something like this:

        Code:
        query = "UPDATE Camera SET CameraName= '" + CameraName + "' WHERE CameraName='" + oldIPCamera.CameraName + "'";

        Comment

        • lazzypink
          New Member
          • Mar 2008
          • 15

          #5
          Originally posted by amitpatel66
          The problem in your update statement is that you are not enclosing the values camera_7 and the other one in a single quotes. Try something like this:

          Code:
          query = "UPDATE Camera SET CameraName= '" + CameraName + "' WHERE CameraName='" + oldIPCamera.CameraName + "'";
          Yup! you are correct, i got what i want. thanks pal..

          Comment

          • amitpatel66
            Recognized Expert Top Contributor
            • Mar 2007
            • 2358

            #6
            Originally posted by lazzypink
            Yup! you are correct, i got what i want. thanks pal..
            You are welcome. Do post back in case of any further issues

            Comment

            Working...