****源代碼
  int id=0;

SqlCommand objcmd = new SqlCommand("spcheckmprno", objcon);
objcmd.CommandType = CommandType.StoredProcedure;
SqlParameter objparam=new SqlParameter("@mprno",SqlDbType.Char);
objparam.Value = mprno;
objcmd.Parameters.Add(objparam);
try
{
objcon.Open();
id = Convert.ToInt16(objcmd.ExecuteScalar().ToString());
objcon.Close();
}
catch (Exception e)
{
throw e;
}
***出錯:
Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: 
Line 91:  catch (Exception e)
Line 92:  {
Line 93:  throw e;
Line 94:  }
Line 95:  if (id == 0)
 
***刪除這行後就可以
//id = Convert.ToInt16(objcmd.ExecuteScalar().ToString());
返回值為空就出錯,不為空不出錯
有什麼辦法解決呀