DataSet ds = new DataSet();strSql = "select * from table1";
mySqlAdapter = new SqlDataAdapter(strSQL,strSqlConn);
mySqlAdapter.Fill(ds,"table1");strSql = "select * from table2";
mySqlAdapter = new SqlDataAdapter(strSQL,strSqlConn);
mySqlAdapter.Fill(ds,"table2");

解决方案 »

  1.   

    DataSet ds = new DataSet();mySqlAdapter = new SqlDataAdapter();
    mySqlAdapter.SelectCommand =new SqlCommand();
    mySqlAdapter.SelectCommand.Connection =conn;strSql = "select * from table1";
    mySqlAdapter.SelectCommand.CommandText =strSql ;
    mySqlAdapter.Fill(ds,"table1");
    strSql = "select * from table2";
    mySqlAdapter.SelectCommand.CommandText =strSql 
    mySqlAdapter.Fill(ds,"table2");
      

  2.   

    if (tableNames != null && tableNames.Length > 0)
    {
    string tableName = "Table";
    for (int index=0; index < tableNames.Length; index++)
    {
    if( tableNames[index] == null || tableNames[index].Length == 0 ) throw new ArgumentException( "The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames" );
    dataAdapter.TableMappings.Add(tableName, tableNames[index]);
    tableName += (index + 1).ToString();
    }
    }
                    
    // Fill the DataSet using default values for DataTable names, etc
    dataAdapter.Fill(dataSet);
      

  3.   

    如果你的存储过程SELECT  两 个表的话
    你用fill(dataset), dataset里面就会有两个表
      

  4.   

    mySqlAdapter.Fill(ds,"table2") 还是mySqlAdapter.Fill[ds,"table2"];