0

How to use ASE Bulk Copy in c# to insert data into Sybase

I tried this code,

            AseBulkCopy f = new AseBulkCopy(con);
            f.BatchSize = 10000;

            string query;
            for(int i=0;i<10000;i++)
            {
                query = "insert into Sample3 values("+i+",'dd')";
                AseCommand cmd = new AseCommand(query,con);
                cmd.ExecuteNonQuery();
            }
            MessageBox.Show("Insertion Complete");
            con.Close();

But it take same time as general please suggest any solution I am new about that

Mike Gardner
  • 6,611
  • 5
  • 24
  • 34

1 Answers1

0

AseBulkCopy is used to insert rows from a C# datatable to a database table. Check the below code:

AseBulkCopy obj_AseBulkCopy = new AseBulkCopy(db_Conn);
obj_AseBulkCopy.DestinationTableName = "db_Table";
obj_AseBulkCopy.BatchSize = 1000;
db_Conn.Open();
obj_AseBulkCopy.WriteToServer(dt_DataTable);
db_Conn.Close();

Using the above code, you will be able to insert all the rows present in the dt_DataTable to db_table in the database.

Harsh
  • 107
  • 1
  • 2
  • 5