Results 1 to 3 of 3

Thread: Error to update PictureBox ?????

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    25

    Error to update PictureBox ?????

    when i try to write Code of Command update i get error in my code...

    Code:
    CmdUpdate.Connection = con
            CmdUpdate.CommandText = "update Properties set   PropertyName=' " & Me.txtpropertyname.Text & " '," & _ 
    "pic1=' " & Me.PictureBox1.Image & " ' , path1=' " & Me.lblpic1.Text & " ', where PropertyID=" & _txtpropertyid.Text

    the Error text which i faced is ...

    Code:
    Operator '&' is not defined for types 'String' and 'System.Drawing.Image'
    So, How i can solve this Error task???

  2. #2
    Addicted Member
    Join Date
    Mar 2006
    Posts
    235

    Re: Error to update PictureBox ?????

    You got a two problems.

    Code:
    "update Properties set   PropertyName=' " & Me.txtpropertyname.Text & " ',"
    will store a leading and trailing space with the propertyname and the other fields your updating in the database.

    Your error may be caused by the underscore here

    Code:
    & _txtpropertyid.Text

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Error to update PictureBox ?????

    You can't just concatenate an Image into a string. An Image is completely incompatible with strings, which is why you get that message. Having said that, you should be using string concatenation to build SQL statements at all.

    Read this thread to see how to create parameterised SQL statements, then read this thread to see how to use a parameterised SQL statement to save an image, as well as retrieve that image again.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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