Link to home
Start Free TrialLog in
Avatar of JCWEBHOST
JCWEBHOST

asked on

sql query in text

hey guys i have a problem.

i can not insert a image to my database using text query?

(object)(Session["image"])

i have a sql = (insert (img)values((object)(Session["image"]))

do not work, couse i pass the text sql to a method

please help?
Avatar of DBAduck - Ben Miller
DBAduck - Ben Miller
Flag of United States of America image

What is the client that runs this SQL text?

In straight TSQL you cannot do this unless it is a binary stream, so the client usually handles putting the data into a binary stream.

NOTE: If you are on SQL 2005, in the future the type "image" is deprecated and will be removed from the product.  I would advise using varbinary(max) instead.  The insert is still the same.
I'd do it using a Parameter on you SqlCommand object that contains the binary list from your Session State - that's what has worked well for me, and it's also a bit easier to read, since it separates the insert itself from the content.
ASKER CERTIFIED SOLUTION
Avatar of keyu
keyu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial