Stored Procedure always returning 0

后端 未结 4 1993
温柔的废话
温柔的废话 2021-01-23 02:26

I am trying to get returned value from stored procedure, but it always returning 0.

c# code

cmd = new SqlCommand();
    cmd.CommandType = CommandType.S         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-23 03:17

    if count is in your select query u should used executescaler.. like

    int result=convert.toint32(cmd.executescalar());
    

    or

    int result = (Int32)cmd.ExecuteScalar();
    

提交回复
热议问题