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???
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
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.