Reset value in ASP.NET for Image data type in SQL Server

1k views Asked by At

In ASP.NET I wish to empty/clear/reset the contents on an Image data type in SQL Server. I will then later check to see if this column is empty/null - if not, I will output the image.

Can you tell me the necessary C#? Here is what I have presently...

newsItem.Image1 = null;
dataContext.SubmitChanges();

The above actually gives me "0x" when I look through SQL Server Management Studio, so its not actually empty.

Many thanks!

2

There are 2 answers

3
PraveenVenu On BEST ANSWER

If it is Nullable in DB then use

newsItem.Image1= null;

else

newsItem.Image1= new Binary( new byte[0] );
0
Travis J On

Couple things come to mind:

  • In your database, is Image nullable?
  • You may have to remove and recreate the entire row of that table to ensure that the field is removed.