- using System;
- using System.Data;
- using System.Data.OleDb;
- class TestADO
- {
- static void Main(string[] args)
- {
- string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\\test.mdb";
- string strSQL = "INSERT INTO Employee(FirstName, LastName) VALUES('FirstName', 'LastName')" ;
- // create Objects of ADOConnection and ADOCommand
- OleDbConnection conn = new OleDbConnection(strDSN);
- OleDbCommand cmd = new OleDbCommand( strSQL, conn );
- try
- {
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- catch (Exception e)
- {
- Console.WriteLine(Oooops. I did it again:\\n{0}, e.Message);
- }
- finally
- {
- conn.Close();
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/191120137278.html
来源: http://www.codesnippet.cn/detail/191120137278.html