try following example,
If NOT IsDbNull(row("PHOTO")) Then
//Do something
ELSE
//your logic goes here
Dim PHOTO as Image=DBNull.Value;
End If
EDIT
As you mentioned in comment, In C# my approach that works for me is...
byte[] bimage = null;
if (txtPic.Text != "")
{
string image = txtPic.Text;
Bitmap bmp = new Bitmap(image);
FileStream fs = new FileStream(image, FileMode.Open, FileAccess.Read);
bimage = new byte[fs.Length];
fs.Read(bimage, 0, Convert.ToInt32(fs.Length));
fs.Close();
}
and now for stored procedure my image parameter will be as
if (bimage != null)
cmd.Parameters.AddWithValue("@imgdata", SqlDbType.Image).Value = bimage;
else
{
SqlParameter imageParameter = new SqlParameter("@imgdata", SqlDbType.Image);
imageParameter.Value = DBNull.Value;
cmd.Parameters.Add(imageParameter);
}
DBNull.Valueand not toNothing?