Multiples Table in DataReader

后端 未结 3 1892
天涯浪人
天涯浪人 2020-12-01 20:29

I normally use DataSet because It is very flexible. Recently I am assigned code optimization task , To reduce hits to the database I am changing two queries in

3条回答
  •  渐次进展
    2020-12-01 21:11

    I built on Pranay Rana's answer because I like keeping it as small as possible.

    string rslt = "";
    using (SqlDataReader dr = cmd.ExecuteReader())
    {
        do
        {
            while (dr.Read())
            {
                rslt += $"ReqID: {dr["REQ_NR"]}, Shpr: {dr["SHPR_NR"]}, MultiLoc: {dr["MULTI_LOC"]}\r\n";
            }
        } while (dr.NextResult());
    }
    

提交回复
热议问题