public void batchinsertintoaccess (DataTable dt) {ADODB. Connection cn; ADODB. Recordset rs; String strconn = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\filetmp\mmscrm.mdb; Persist Security Info=false "; cn = New ADODB. Connection (); cn. ConnectionString = strconn; Open the database try {//cn. Open (strconn, "sa", "Password",-1); cn. Open (strconn); } catch (Exception ex) {throw new Exception (ex). Message); } finally {Console.WriteLine (CN. State); }//Open record Set rs = new ADODB. Recordset (); Rs. LockType = ADODB. locktypeenum.adlockpessimistic; Rs. CursorType = ADODB. cursortypeenum.adopendynamic; Rs. Open ("Msg_outbox", CN); If the recordset is empty, output an error message for (int i = 0; i < 10;i++) {Rs. MOvelast (); Object missing = System.Reflection.Missing.Value; Rs. AddNew (missing, missing); The No. 0 column is self-increment, ignoring Rs. FIELDS[1]. Value = "2"; Rs. FIELDS[2]. Value = ""; Rs. FIELDS[3]. Value = "11111111"; Rs. FIELDS[4]. Value = "0"; Rs. FIELDS[5]. Value = "Sent to send Dfadafdadafde"; Rs. FIELDS[6]. Value = ""; Rs. FIELDS[7]. Value = "2016/10/1 22:23:48"; Rs. FIELDS[8]. Value = 12; Rs. Update (); } rs. Close (); cn. Close (); }
C # calls ADODB to perform bulk inserts on an Access database