c.Open()
r = x.ExecuteReader
If Not r("filename").IsDbnull Then
imagepath = "<img src='images/'" & getimage(r("filename")) & " border='0' align='absmiddle'"
End If
c.Close()
r.Close()
I have also tried;
If r("filename") Is DBNull.Value Then
imagepath = String.Empty
Else
imagepath = "<img src='images/'" & getimage(r("filename")) & " border='0' align='absmiddle'"
End If
c.Close()
r.Close()
The error is: Invalid attempt to read when no data is present.
The idea of my code is to build an img src string only when data is available.
Help greatly appreciated.
Thanks
You need to call the
Readmethod on yourSqlDataReaderbefore data is available for reading.