我试图在 C# 中连接 MS Access Db 并想查看全部。我的 Db 连接代码如下所示
String conStr= @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\SMSGateway2\SMS.mdb;Persist Security Info=True; Jet OLEDB:Database Password=testing" ;
OleDbConnection con;
con = new OleDbConnection(conStr);
string cmdString = "select * from Temp_Order";
OleDbCommand command = new OleDbCommand(cmdString, con);
try
{
con.Open();
command.ExecuteNonQuery();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
richTextBox1.Text = "Student Name: " + reader["SenderNo"].ToString() + "\n" +
"ID: " + reader["OrgerView"].ToString() + "\n" +
"Program: " + reader["OrderTime"].ToString() + "\n" +
"Address: " + reader["Flag"].ToString();
}
}
catch (Exception readexcp)
{
throw readexcp;
}
finally
{
con.Close();
}