public void CreateDataTableInDatabaseTest()
        {
            const string TableName = "TempTable";

            // create the datatable and add some columns
            var dataTable = new DataTable();

            dataTable.TableName = TableName;
            dataTable.Columns.Add(
                new DataColumn()
            {
                DataType = Type.GetType("System.Int32"), ColumnName = "RowID", AutoIncrement = true
            });
            dataTable.Columns.Add(
                new DataColumn()
            {
                DataType = Type.GetType("System.String"), ColumnName = "Col1"
            });
            dataTable.Columns.Add(
                new DataColumn()
            {
                DataType = Type.GetType("System.Int32"), ColumnName = "Col2"
            });

            SqlTableBuilder.CreateTableSchemaFromDataTable(testDatabase.ConnectionString, dataTable);

            Assert.IsTrue(this.TableExists(TableName, testDatabase.ConnectionString));
        }
Beispiel #2
0
        internal SqlBulkInsertAdapter(string schemaFileName, string connectionString, int batchSize = 1000)
        {
            this.connectionString = connectionString;
            this.batchSize        = batchSize;
            this.dataTable        = this.GenerateDataTableFromXmlFile(schemaFileName);

            // use the db connections to create table schema in the database
            SqlTableBuilder.CreateTableSchemaFromDataTable(connectionString, this.dataTable);
        }