日期:2014-05-18 浏览次数:20917 次
private void Form1_Load(object sender, EventArgs e) { string connStr, selectCmd; int i; connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SCOREDB.mdb"; selectCmd = "SELECT * FROM SCORE"; OleDbConnection conn; OleDbCommand cmd; OleDbDataReader reader; conn = new OleDbConnection(connStr); conn.Open(); cmd = new OleDbCommand(selectCmd, conn); reader = cmd.ExecuteReader(); for (i = 0; i < reader.FieldCount; i++) { txtShow.Text += reader.GetName(i) + "\t"; } txtShow.Text += "\n\n"; while (reader.Read()) { for (i = 0; i < reader.FieldCount; i++) { txtShow.Text += reader[i] + "\t"; } txtShow.Text += "\n"; } conn.Close(); }