in databse tabel i have fieild with type varbinary(max) for storing image,
so i achieved it and stored my image but the problem is that when i use this line

SqlParameter p8 = new SqlParameter("logo", SqlDbType.VarBinary).Value= productImage;

then it gives me an error but when i use this line :

 com.Parameters.Add("@logo", SqlDbType.VarBinary).Value = productImage;

then it works , WHY ??????

NoteL i am using asp.net 3.5 + sql server 2008 , and using SP to execute it which i achieved but confused about the problem above. HELP !

Recommended Answers

All 2 Replies

I dont have experience with storing images in a DB, but the first question is are you sure that you want to go down this path? Depending on the number images, your database will grow quite large. Is there a reason not to simply store the path to the image in a table?

In the first line you are attempting to create an object of type sqlParameter, while in the second line you are simple adding the value of productImage to the parameters property of the SQL command object.

The use of paramters is the preferred method. You should have a sql statement in your code that references that parameter called @logo.

This goes back to some of your other threads where you have tried to use the querystring directly with the sql statement. The use of parameters is one more layer of security for your application.

commented: ok jorgem i changed my way of storing images , i am now storing a path only +0

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.