This error is most likely due to the fact that the SQL statement you constructed does not yield any rows.
string sql="select photo FROM joining where refno='" + v +"' ";
This would yield something like:
select photo FROM joining where refno='xxxxxx'
where xxxxxx is some suitable value for which there are records in table
joining
.
Caveat: Please do not construct your SQL in such a fashion as it leaves your code vulnerable to SQL injection attacks. Use
SQLParameter
to parameterize your SQL statements. This will be of added benfit as you will not have to deal with proper formatting and escaping stuff.
Regards,
Manfred