Possible to return an out parameter with a DataReader

后端 未结 2 829
自闭症患者
自闭症患者 2021-01-17 12:24

Using ExecuteReader I am able to return a DataReader, but the out parameter is returning 0.

Using ExecuteNonQuery I am able to retrieve the

2条回答
  •  孤街浪徒
    2021-01-17 13:10

    To get the values from OUTPUT parameters with SqlDataReader you can only after the reader will be closed.

    So you need to add this code before you try to get the values

    if(!dataReader.IsClosed)
        dataReader.Close(); 
     if(out_recordCount.Value != DBNull.Value)
         recordCount = Convert.ToInt64(out_recordCount.Value);
     returnValue = Convert.ToInt32(return_Value.Value);
    

提交回复
热议问题