Ajay Patel

Ajay Patel

  • NA
  • 147
  • 251.8k

Get result from SQL by Where Condition on Image Datatype Col

Oct 15 2013 1:42 AM
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.

Answers (3)