title: return exception when run one stored procedure
body: <p>I have this stored procedure</p>
  
  <pre><code>create PROCEDURE spgetoutpatientidbyinpatientid
  @pinpatientid int
  AS
  
  BEGIN
  
  select  Patient_ID 
      from tblPatientAdmissionDetails 
      where ID=@pinpatientid and Status=1
  END
  GO
  </code></pre>
  
  <p>if this condition is wrong i got null exception.I want to return at least null value or anything.how can i avoid this error. In my code I use </p>
  
  <pre><code>&lt;pre lang="c#"&gt;string  ds = UserDataBase.ExecuteScalar(Command).ToString();&lt;/pre&gt;
  </code></pre>
  
  <p>How can I change my sql query..? or how can I avoid this exception</p>