Return multiple recordsets from stored proc in C#

后端 未结 4 1025
时光取名叫无心
时光取名叫无心 2020-12-05 20:38

I am having to convert an ASP classic system to C#

I have a stored procedure that can return up to 7 recordsets (depending on the parameters passed in).

I ne

4条回答
  •  忘掉有多难
    2020-12-05 21:11

    this will return you all you need

    using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
    {
        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.CommandText = "yoursp";
            cmd.Connection = conn;
            cmd.CommandType = CommandType.StoredProcedure;
    
            conn.Open();
    
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
    
            DataSet ds = new DataSet();
            adapter.Fill(ds);
    
            conn.Close();
        }
    }
    

提交回复
热议问题