using System; using System.Data; using System.Data.OleDb; namespace ADONETWriteQuery { /**//// <summary> /// Summary description for Class1. /// </summary> class Class1 { static void Main(string[] args) { string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\mcTest.MDB"; string strSQL = "INSERT INTO Developer(Name, Address ) VALUES( 'NewName', 'NewAddress')" ; // create Objects of ADOConnection and ADOCommand OleDbConnection myConn = new OleDbConnection(strDSN); OleDbCommand myCmd = new OleDbCommand( strSQL, myConn ); try { myConn.Open(); myCmd.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine("Oooops. I did it again:\n{0}", e.Message); } finally { myConn.Close(); } } } } 转载于:https://www.cnblogs.com/virusswb/articles/1238276.html