Returning a single row

前端 未结 10 2320
野的像风
野的像风 2021-02-13 06:58

I\'m trying to return a single row from a database:

using (connection = new SqlConnection(ConfigurationManager.AppSettings[\"connection\"]))
{
    using (command         


        
10条回答
  •  说谎
    说谎 (楼主)
    2021-02-13 07:28

    The problem is the return type. The method you are in is expecting you to return a string, but reader["col_1"] is an object. I suggest returning reader["col_1"].ToString() or Convert.ToString(reader["col_1"]).

提交回复
热议问题