/// <summary> /// Method which does the SQL Bulk Copy /// </summary> /// <param name="fileName">CSV Load file name, can need the path as well /// connectString">Connect string to the SQL Server database to load to /// rowBufferLength">The size of the "pipe" which buffers the read rows.</param> /// <param name="rowBufferLength"></param> /// <returns>The results of the load operation</returns> public SqlLoadResults LoadData(string fileName, int rowBufferLength, DataTable dTables, int dcountId, string typeProcess) { _filename = fileName; // Pull the table name from the CSV file name string tableName = ParseFileName(fileName); DateTime start = DateTime.Now; // High accuracy time measurement Stopwatch sw = new Stopwatch(); sw.Start(); // Build the class which reads the CSV data. CSVDataReader reader = new CSVDataReader(fileName, rowBufferLength); // Connect to the db DatatableExcel.DcountId = 0; if (typeProcess.Equals(Constant.TYPE_1)) { DatatableExcel.ProcessTable_1(fileName, dTables, typeProcess); } else { DatatableExcel.ProcessTable_2(fileName, dTables, typeProcess); } DateTime end = DateTime.Now; sw.Stop(); // Return the load summary object return new SqlLoadResults( fileName, start, end, reader.RowsRead, 0L, sw.ElapsedMilliseconds, reader.RowsReturned); }
/// <summary> /// Method which does the SQL Bulk Copy /// </summary> /// <param name="fileName">CSV Load file name, can need the path as well /// connectString">Connect string to the SQL Server database to load to /// rowBufferLength">The size of the "pipe" which buffers the read rows.</param> /// <returns>The results of the load operation</returns> public SqlLoadResults LoadData(string fileName, int rowBufferLength) { _filename = fileName; // Pull the table name from the CSV file name string tableName = ParseFileName(fileName); DateTime start = DateTime.Now; // High accuracy time measurement Stopwatch sw = new Stopwatch(); sw.Start(); // Build the class which reads the CSV data. CSVDataReader reader = new CSVDataReader(fileName, rowBufferLength); // Connect to the db //common.create(fileName); DateTime end = DateTime.Now; sw.Stop(); // Return the load summary object return new SqlLoadResults( fileName, start, end, reader.RowsRead, 0L, sw.ElapsedMilliseconds, reader.RowsReturned); }