nisar ahmad

nisar ahmad

  • NA
  • 12
  • 0

handling null in byte[]

May 11 2011 3:55 AM
Dear All,

I have a windows service which is the bridge between two databases, it fetch records from one database and put it in other, the problem is i have byte[] variable in which i reterived the image from database and push that value in other database it works fine if the value reterived is not null but if the value reterived is null it gives exception, what i want is to handle null value and if it null i will store null. find the below code

 SqlCommand com = new SqlCommand("select _CHEQUE_FRONT_IMG from V_NB where Transaction_id=" + _tranid, sqlConn);
                byte[] b = (byte[])com.ExecuteScalar();//here is the point where it gives exception when it get null

Please help in this regard

Answers (4)