C # calls ADODB to perform bulk inserts on an Access database

Source: Internet
Author: User
Tags access database

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.