Hello,
I have a table in SQL that has Image datatype column.
Now I pass Byte[] array in Parameter for where condition on Image Column but I didn't find any result.
here is my Code.
IN SQL :
SELECT * FROM tblnotifications where CONVERT(VarBinary, img)=( SELECT CONVERT(VarBinary, img) FROM tblnotifications where ID = 2)
This is working fine.
But in C#:
string strExist = "Select * from tblnotifications Where CONVERT(VARBINARY,Mugshot) = @Mugshot";
dbp = new DbParameters();
dbp.SetParameter("@Mugshot", lstXCADData[j].Mugshot, SqlDbType.VarBinary, 16);
DataSet dsExist = Query.DataSet(strExist, dbp, PoolName);
This is not working. so how can I do this.
Get result from SQL by Where Condition on Image Datatype Col
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Sakthis50 reputationPosted Oct 15, 2013, 1:50 AM EDT
Ajay Patel148 reputationPosted Oct 15, 2013, 8:51 PM EDT
Thanks for reply.
I don't think that solution can work. as Binary and varbinary are both BLOB datatype.
Ajay Patel148 reputationPosted Jan 6, 2014, 8:51 AM EST
You can't directly compare image datatype. so you can do it by converting image type to nvarchar / varchar type