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();
}