Beispiel #1
0
        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();
                }
            }
        }
Beispiel #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();
                }
            }
        }
Beispiel #3
0
 public void Dispose()
 {
     if (dataReader != null)
     {
         dataReader.Dispose();
         dataReader = null;
     }
 }
Beispiel #4
0
 public FileDataReader ExecuteReader(CommandBehavior behavior)
 {
     dataReader = new FileDataReader(file);
     return(dataReader);
 }
Beispiel #5
0
 private void InitializeMembers()
 {
     this.file       = null;
     this.dataReader = null;
 }
Beispiel #6
0
 public void Dispose()
 {
     if (dataReader != null)
     {
         dataReader.Dispose();
         dataReader = null;
     }
 }
Beispiel #7
0
 private void InitializeMembers()
 {
     this.file = null;
     this.dataReader = null;
 }
Beispiel #8
0
 public FileDataReader ExecuteReader(CommandBehavior behavior)
 {
     dataReader = new FileDataReader(file);
     return dataReader;
 }