Problem with DBNull values for binary images

  • Thread starter Thread starter Ola Myrgart
  • Start date Start date
O

Ola Myrgart

Hi !

I´ve this code in my application for checking null values when inserting
a [BinaryArray] (picture) into my SQL DB:

If (ImageFile.PostedFile.ContentLengt =< 0) then

sqlCommand.Parameters.Add("@Bild", sqlDbType.Image).Value =
System.DBNull.Value

Else

sqlCommand.Parameters.Add("@Bild", sqlDbType.Image),Value = byteData

End If


I get a errormessage. Any suggestions how to solve this I would be much
greatful..!
The code works fine if I apply it to ordinary textfields controls like
name.txt but not with the ImageFile - Why ?


OM "Myggan"
 
Hi !

Yes I suppose the targetcolumn accepts "null" values. The columnformat
is "Image". Don´t know if that´s a problem when it comes to Nullvalues?

The Errormessage is : Expression expected


Line 83: If (ImageFile.PostedFile.ContentLength =< "0") then
Line 84: sqlCommand.Parameters.Add("@Bild", SqlDbType.Image).Value =
System.DBNull.Value
Line 85: Else


Any ideas ?

OM "Myggan"
 
Hi Ola,

Is error happening in line 83?
Why are comparing to string "0"?
Is ImageFile.PostedFile.ContentLength valid number?
 
Hi !

Yes I suppose the targetcolumn accepts "null" values. The columnformat
is "Image". Don´t know if that´s a problem when it comes to Nullvalues?

The Errormessage is : Expression expected


Line 83: If (ImageFile.PostedFile.ContentLength =< "0") then
Line 84: sqlCommand.Parameters.Add("@Bild", SqlDbType.Image).Value =
System.DBNull.Value
Line 85: Else


Any ideas for Line 83 ?

OM "Myggan"
 
Hi again !

Yes the errormessage comes from Line83.

Line 83: If (ImageFile.PostedFile.ContentLength =< "0") then

Maybe it should be:

Line 83: If (ImageFile.PostedFile.ContentLength =< 0) then

OM "Myggan"
 
Back
Top