我试过了大侠的方法 但是还是出错啊
不知道为什么啊
string connectionString =
"provider=Microsoft.Jet.OLEDB.4.0;" +
"data source=C:\\Documents and Settings\\Administrator.310C7DBA925B462\\桌面\\db2.mdb";
OleDbConnection myOleDbConection = new OleDbConnection(connectionString);
OleDbCommand myOleDbCommand = new OleDbCommand("Insert into db2(customerID, CompanyName, contactName, Address) values('sfd','jkl','hf','jy');", myOleDbConection);/*SELECT customerID, CompanyName, contactName, Address "+
"FROM db2 "+
"WHERE (((customerID)='ALFKI'));", myOleDbConection);*/
/* string sql;
sql = "SELECT customerID, CompanyName, contactName, Address " +
"FROM db2 " +
"WHERE (((customerID)='ALFKI'));" + "CREAT TABLE 学生 (学号 CHAR(5) NOT NULL UNIQUE,姓名 CHAR(8) NOT NULL,年龄 SMALLINT,性别 CHAR(2),所在系 CHAR(20));";// +
//"DEFOAULT C1 20 FOR 年龄,CONSTRAINT C2 CHECK (性别 IN('男','女')));";
OleDbCommand myOleDbCommand = new OleDbCommand(sql, myOleDbConection);*/
/*OleDbCommand myOleDbCommand = myOleDbConection.CreateCommand();//new OleDbCommand("select * from db2", myOleDbConection);
=
"SELECT customerID,CompanyName,contactName,Adress " +
"FROM db2 " +
"WHERE cunstomerID ='ALFKI';";*/
myOleDbConection.Open();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
OleDbCommand myOleDbCommand1 = new OleDbCommand("SELECT customerID, CompanyName, contactName, Address " +
"FROM db2 " +
"WHERE (((customerID)='ALFKI'));", myOleDbConection);
//myOleDbConection.Open();
OleDbDataReader myOleDbDataReader1 = myOleDbCommand1.ExecuteReader();
myOleDbDataReader.Read();
Console.WriteLine(myOleDbDataReader1["customerID"]);
Console.WriteLine(myOleDbDataReader1["CompanyName"]);
Console.WriteLine(myOleDbDataReader1["contactName"]);
Console.WriteLine(myOleDbDataReader1["Address"]);
myOleDbDataReader1.Close();
myOleDbConection.Close();
string wait = Console.ReadLine();