private void ExecuteBulkInsert(FileDataReader dr)
        {
            var cstr = Test.Constants.TestConnectionString;
            var dropsql = "IF OBJECT_ID('testtable','U') IS NOT NULL DROP TABLE testtable";
            var createsql = "CREATE TABLE testtable (one int, two int, three int)";

            using (var cn = new SqlConnection(cstr))
            {
                cn.Open();

                // Drop table first
                using (var cmd = new SqlCommand(dropsql, cn))
                {
                    cmd.ExecuteNonQuery();
                }

                // Create empty table
                using (var cmd = new SqlCommand(createsql, cn))
                {
                    cmd.ExecuteNonQuery();
                }

                // Run bulk-insert
                var bcp = new SqlBulkCopy(cn);
                bcp.DestinationTableName = "testtable";
                bcp.WriteToServer(dr);

                // Drop table
                using (var cmd = new SqlCommand(dropsql, cn))
                {
                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemple #2
0
        private void ExecuteBulkInsert(FileDataReader dr)
        {
            var cstr      = Jhu.Graywulf.Test.AppSettings.IOTestConnectionString;
            var dropsql   = "IF OBJECT_ID('testtable','U') IS NOT NULL DROP TABLE testtable";
            var createsql = "CREATE TABLE testtable (one int, two int, three int)";

            using (var cn = new SqlConnection(cstr))
            {
                cn.Open();

                // Drop table first
                using (var cmd = new SqlCommand(dropsql, cn))
                {
                    cmd.ExecuteNonQuery();
                }

                // Create empty table
                using (var cmd = new SqlCommand(createsql, cn))
                {
                    cmd.ExecuteNonQuery();
                }

                // Run bulk-insert
                var bcp = new SqlBulkCopy(cn);
                bcp.DestinationTableName = "testtable";
                bcp.WriteToServer(dr);

                // Drop table
                using (var cmd = new SqlCommand(dropsql, cn))
                {
                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemple #3
0
 public void Dispose()
 {
     if (dataReader != null)
     {
         dataReader.Dispose();
         dataReader = null;
     }
 }
Exemple #4
0
 public FileDataReader ExecuteReader(CommandBehavior behavior)
 {
     dataReader = new FileDataReader(file);
     return(dataReader);
 }
Exemple #5
0
 private void InitializeMembers()
 {
     this.file       = null;
     this.dataReader = null;
 }
Exemple #6
0
 public void Dispose()
 {
     if (dataReader != null)
     {
         dataReader.Dispose();
         dataReader = null;
     }
 }
Exemple #7
0
 private void InitializeMembers()
 {
     this.file = null;
     this.dataReader = null;
 }
Exemple #8
0
 public FileDataReader ExecuteReader(CommandBehavior behavior)
 {
     dataReader = new FileDataReader(file);
     return dataReader;
 }