예제 #1
0
        private void InsertTableDataExpress(SqlConnection conn, string tableName)
        {
            AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();

            tableName = "dbo." + tableName;

            lbProgressStage.Text = "inserting data into table : " + tableName;
            this.Refresh();
            try
            {
                SqlBulkCopy sbc = new SqlBulkCopy(conn, SqlBulkCopyOptions.KeepIdentity, null);
                using (SqlConnection cConn = lAuditWizardDataAccess.CreateOpenConnection())
                {
                    SqlCommand    cmd = new SqlCommand("SELECT * FROM " + tableName, cConn);
                    SqlDataReader rdr = cmd.ExecuteReader();

                    sbc.DestinationTableName = tableName;
                    sbc.BulkCopyTimeout      = 120;
                    sbc.WriteToServer(rdr);
                }

                progressBar1.PerformStep();
                this.Refresh();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }