create   proc test_proAS
set nocount on
select * from answers
select * from msg
select * from tree
set nocount off conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Connection"].ToString());
da=new SqlDataAdapter("test_pro",conn);
da.SelectCommand.CommandType=CommandType.StoredProcedure;
ds=new DataSet();
da.Fill(ds);
int count=ds.Tables.Count;//为什么这里的count没有数值,我希望得到的是ds里面有 table0,table1,table2。

解决方案 »

  1.   

    try
    {
    conn=new Speciality.Connection().Conn();
    conn.Open();
    da=new SqlDataAdapter("test_pro",conn);
    da.SelectCommand.CommandType=CommandType.StoredProcedure;
    ds=new DataSet();
    da.Fill(ds);
    int count=ds.Tables.Count;
    }
    catch(SqlException ex)
    {
    Speciality.JScript.Alert(ex.Message);
    }
    finally
    {
    conn.Close();
    }
      

  2.   

    try
    {
    conn=new Speciality.Connection().Conn();
    conn.Open();
    da=new SqlDataAdapter("test_pro",conn);
    da.SelectCommand.CommandType=CommandType.StoredProcedure;
    ds=new DataSet();
    da.Fill(ds);
    int count=ds.Tables.Count;
    }
    catch(SqlException ex)
    {
    Speciality.JScript.Alert(ex.Message);
    }
    finally
    {
    conn.Close();
    }
      

  3.   

    可以的,DataSet中可以存放若干张DataTable
      

  4.   

    可以做到的,我刚刚还在用呢
    每个查询语句要用分句隔开:
    sql="Select * from tables1;select * from tables;Update tables1 set aa=1"
    Da=New SqlDataAdapter(sql,conn)
    Da.Fill(Ds)
      

  5.   

    这是我的存储过程 :
    create   proc test_proAS
    set nocount on
    select * from answers
    select * from msg
    select * from tree
    set nocount off这里我的后台命令:
    try
    {
    conn=new Speciality.Connection().Conn();
    if(conn.State==System.Data.ConnectionState.Closed)
    conn.Open();
    da=new SqlDataAdapter("test_pro",conn);
    da.SelectCommand.CommandType=CommandType.StoredProcedure;
    ds=new DataSet();
    da.Fill(ds);
    DataGrid1.DataSource=ds.Tables["Table0"].DefaultView;
    DataGrid1.DataBind();
    int count=ds.Tables.Count;
    }
    catch(SqlException ex)
    {
    Speciality.JScript.Alert(ex.Message);
    }
    finally
    {
    if(conn.State==System.Data.ConnectionState.Open)
    conn.Close();
    }
    为什么我的 ds.Tables["Table0"] 值为空啊?
      

  6.   

    int count=ds.Tables.Count;//为什么这里的count没有数值,我希望得到的是ds里面有 table0,table1,table2。应该是这样的:table0 的记录数:ds.Tables(0).rows().count
    table1 的记录数:ds.Tables(1).rows().count
      

  7.   

    用ds.Tables[0].DefaultView 换试一下。
      

  8.   

    select * from answers
    select * from msg
    select * from tree
    你返回的3个表用SqlDataAdapter.Fill到一个DataSet中,这个应该很简单吧访问时候使用
    DataTable dt1 = DataSet.Table[0]
    DataTable dt2 = DataSet.Table[1]
    DataTable dt3 = DataSet.Table[2]接着用DataRow[][]访问具体数据
      

  9.   

    ps: 取得count 需要dt1.Rows.Count 且Count返回的是int
      

  10.   

    不好意思,我以为 da.fill(ds)中的表名默认为 table0, table1,table2
      

  11.   

    要是弄不明白  我的做法是弄一个强类型的dataset看看就知道了
      

  12.   

    table0 的记录数:ds.Tables(0).rows().count这样应该可以
      

  13.   

    ds.Tables[0]
    ds.Tables[1]
    ds.Tables[2]
      

  14.   

    create proc test
    AS
    select * from aa
    select * from bb
    select * from ccthis.DataAdapter = new System.Data.SqlClient.SqlDataAdapter("test",this.Con);
    this.DataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
    this.DSet = new DataSet();
    this.DataAdapter.Fill(this.DSet,"A");
    MessageBox.Show(this.DSet.Tables.Count.ToString());Table1  A
    Table2  A1
    Table3  A2