我有一个存储过程最后一句是返回一个数据集(select uname from userbase)请问我在c#里怎么接收它呢?

解决方案 »

  1.   

    //定义数据库的Connection and Command
    SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
    SqlDataAdapter da = new SqlDataAdapter("Pr_GetChannels",myConnection);

    //定义访问数据库的方式为存储过程
    da.SelectCommand.CommandType = CommandType.StoredProcedure;
    myConnection.Open(); DataSet ds = new DataSet(); da.Fill(ds);
      

  2.   

    直接这样!
    DataGrid1.DataSource = myCommand.ExecuteReader();
    DataGrid1.DataBind();
    也可以用dataset先接收