Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Bulk Insert asp.net Datatable to Mysql

$
0
0

Hi Support,

I am trying to do bulk insert my datatable to mysql table.

Below code works for inserting table when fetching from table ..but i need to pass Datatable and insert..pl suggest or if you can provide working sample

using (MySqlTransaction tran = conn.BeginTransaction(System.Data.IsolationLevel.Serializable)){
    using (MySqlCommand cmd =newMySqlCommand()){
        cmd.Connection= conn;
        cmd.Transaction= tran;
        cmd.CommandText="SELECT * FROM testtable";
        using (MySqlDataAdapter da =newMySqlDataAdapter(cmd)){
            da.UpdateBatchSize=1000;
            using (MySqlCommandBuilder cb =newMySqlCommandBuilder(da)){
                da.Update(rawData);
                tran.Commit();}}}}

Viewing all articles
Browse latest Browse all 1350


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>