如何判断数据库操作以后返回object 类型的值为NULL

   若有以下代码操作存储过程:
   SqlCommand borrowbook=new SqlCommand();
   borrowbook.Connection=this.sqlConnection1;
   borrowbook.CommandType=CommandType.StoredProcedure;
   borrowbook.CommandText="dbo.StoredProcedureBookNumber";
   SqlParameter parinput=borrowbook.Parameters.Add("@BookID",SqlDbType.Char);
   parinput.Direction=ParameterDirection.Input;
   parinput.Value=BookID;
   SqlParameter paroutput=borrowbook.Parameters.Add("@BookNumber",SqlDbType.Int);
   paroutput.Direction=ParameterDirection.Output;
   try
   {
    this.sqlConnection1.Open();   
    borrowbook.ExecuteNonQuery();
    this.sqlConnection1.Close();
                if ( paroutput.Value!=DBNull.Value )
                    return Convert.ToInt16(paroutput.Value);
                else
                    return -1;

    
   }
   catch(System.Exception e)
   {
    this.ErrorHandle(e);    
    this.sqlConnection1.Close();
    return 0;

   }

posted @ 2007-08-01 16:52  yifan  阅读(1536)  评论(0)    收藏  举报