I am saving photo in SQL (varbinary(MAX) Data Type) with this code:
if (SPV1 == true)
{
imgVC1 = Image.FromFile(Open1.FileName);
imgFormat1 = picVisit1.BackgroundImage.RawFormat;
Ms1 = new MemoryStream();
imgVC1.Save(Ms1, imgFormat1);
byte[] ArrayV1 = Ms1.GetBuffer();
csCompanies.VisitCard1 = ArrayV1;
}
else
csCompanies.VisitCard1 = null;
and it continues with this code in Class:
if(VisitCard1==null)
com.Parameters.AddWithValue("@VisitCard1", Convert.ToByte(VisitCard1));
else
com.Parameters.AddWithValue("@VisitCard1", VisitCard1);
I Used "If" and "Else" for saving "Null" Value, when user not changed default photo.
Null Data saved as "0x00" in SQL.
When I want show data, i want know that the Data in SQL is Null or not, if is Null, do something, and if not, do something !
But i can't compare Data of SQL with Null value! and when i am using
if(cscompanies.Logo1==Null)
result always is (False) [that mean its not Null, Even when it Saved as Null (0x00)