如题,请指点下

解决方案 »

  1.   

    参考  
    sqlstr = "select * from table1 where id = 1";
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = conn;
                cmd.CommandText = sqlstr;
                conn.Open();
                OleDbDataReader reader;
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string s = reader["id"].ToString();
                }
                conn.Close();
      

  2.   

    在ADO.NET 2.0中使用
    DataTable.CreateDataReader 方法 private static void TestCreateDataReader(DataTable dt)
    {
        // Given a DataTable, retrieve a DataTableReader
        // allowing access to all the tables' data:
        using (DataTableReader reader = dt.CreateDataReader())
        {
            do
            {
                if (!reader.HasRows)
                {
                    Console.WriteLine("Empty DataTableReader");
                }
                else
                {
                    PrintColumns(reader);
                }
                Console.WriteLine("========================");
            } while (reader.NextResult());
        }
    }private static DataTable GetCustomers()
    {
        // Create sample Customers table, in order
        // to demonstrate the behavior of the DataTableReader.
        DataTable table = new DataTable();    // Create two columns, ID and Name.
        DataColumn idColumn = table.Columns.Add("ID", typeof(int));
        table.Columns.Add("Name", typeof(string));    // Set the ID column as the primary key column.
        table.PrimaryKey = new DataColumn[] { idColumn };    table.Rows.Add(new object[] { 1, "Mary" });
        table.Rows.Add(new object[] { 2, "Andy" });
        table.Rows.Add(new object[] { 3, "Peter" });
        table.Rows.Add(new object[] { 4, "Russ" });
        return table;
    }private static void PrintColumns(DataTableReader reader)
    {
        // Loop through all the rows in the DataTableReader
        while (reader.Read())
        {
            for (int i = 0; i < reader.FieldCount; i++)
            {
                Console.Write(reader[i] + " ");
            }
            Console.WriteLine();
        }
    }
      

  3.   

    DataSet里的数据可以直接访问例如string[] sArr = new string[ds.tables[0].rows.count]
    for(int i=0;i<ds.tables[0].rows.count;i++)
    {
         sArr[i] = ds.tables[0].rows[i]["id"].tostring();
    }
      

  4.   

    你都有DataSet 了,还用 DataReader 做什么 ??????你自己不烦啊
      

  5.   

    dataReader.Read方法读取当前表的内容,dataReader.NextResult读取下一个表的内容,如果存在.