Class MsAccessBulkInsert
The calss for fast bulk insert big amount of data into Microsoft Access database.
Inheritance
Implements
Namespace: Kros.Data.BulkActions.MsAccess
Assembly: Kros.Utils.MsAccess.dll
Syntax
public class MsAccessBulkInsert : IBulkInsert, IDisposable
Remarks
In the background, it creates a text CSV file with data which are inserted.
Constructors
MsAccessBulkInsert(OleDbConnection)
Creates a new instance with database connection connection
and default settings for CSV file.
Declaration
public MsAccessBulkInsert(OleDbConnection connection)
Parameters
Type | Name | Description |
---|---|---|
System.Data.OleDb.OleDbConnection | connection | Database connection where the data will be inserted. The connection mus be opened. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Value of |
MsAccessBulkInsert(OleDbConnection, OleDbTransaction)
Creates a new instance with database connection connection
, transaction
externalTransaction
and default settings for CSV file.
Declaration
public MsAccessBulkInsert(OleDbConnection connection, OleDbTransaction externalTransaction)
Parameters
Type | Name | Description |
---|---|---|
System.Data.OleDb.OleDbConnection | connection | Database connection where the data will be inserted. The connection mus be opened.
If there already is running transaction in this connection, it must be specified in
|
System.Data.OleDb.OleDbTransaction | externalTransaction | Transaction in which the bulk insert will be performed. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Value of |
MsAccessBulkInsert(OleDbConnection, OleDbTransaction, Int32)
Creates a new instance with database connection connection
, transaction
externalTransaction
and CSV file code page csvFileCodePage
.
Declaration
public MsAccessBulkInsert(OleDbConnection connection, OleDbTransaction externalTransaction, int csvFileCodePage)
Parameters
Type | Name | Description |
---|---|---|
System.Data.OleDb.OleDbConnection | connection | Database connection where the data will be inserted. The connection mus be opened.
If there already is running transaction in this connection, it must be specified in
|
System.Data.OleDb.OleDbTransaction | externalTransaction | Transaction in which the bulk insert will be performed. |
System.Int32 | csvFileCodePage | Code page for generated CSV file. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Value of |
MsAccessBulkInsert(OleDbConnection, OleDbTransaction, Int32, Char)
Creates a new instance with database connection connection
, transaction
externalTransaction
and CSV file settings csvFileCodePage
and valueDelimiter
.
Declaration
public MsAccessBulkInsert(OleDbConnection connection, OleDbTransaction externalTransaction, int csvFileCodePage, char valueDelimiter)
Parameters
Type | Name | Description |
---|---|---|
System.Data.OleDb.OleDbConnection | connection | Database connection where the data will be inserted. The connection mus be opened.
If there already is running transaction in this connection, it must be specified in
|
System.Data.OleDb.OleDbTransaction | externalTransaction | Transaction in which the bulk insert will be performed. |
System.Int32 | csvFileCodePage | Code page for generated CSV file. |
System.Char | valueDelimiter | Value delimiter for generated CSV file. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Value of |
MsAccessBulkInsert(String)
Creates a new instance with database connection specifiend in connectionString
and default settings for CSV file.
Declaration
public MsAccessBulkInsert(string connectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | Connection string for the database connection where the data will be inserted. |
Fields
AnsiCodePage
ANSI code page.
Declaration
public const int AnsiCodePage = 2147483647
Field Value
Type | Description |
---|---|
System.Int32 |
DefaultCodePage
Default code page: Utf8CodePage.
Declaration
public const int DefaultCodePage = 65001
Field Value
Type | Description |
---|---|
System.Int32 |
DefaultValueDelimiter
Default value separator for CSV file: comma (,).
Declaration
public const char DefaultValueDelimiter = ','
Field Value
Type | Description |
---|---|
System.Char |
OemCodePage
OEM code page.
Declaration
public const int OemCodePage = 2147483646
Field Value
Type | Description |
---|---|
System.Int32 |
Utf8CodePage
UTF-8 code page: 65001.
Declaration
public const int Utf8CodePage = 65001
Field Value
Type | Description |
---|---|
System.Int32 |
WindowsCentralEuropeCodePage
Windows Central Europe code page: 1250.
Declaration
public const int WindowsCentralEuropeCodePage = 1250
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
BatchSize
This setting is not used.
Declaration
public int BatchSize { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
BulkInsertTimeout
This setting is not used.
Declaration
public int BulkInsertTimeout { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
CodePage
Code page used for CSV file and bulk insert. Default value is 65001 Utf8CodePage.
Declaration
public int CodePage { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Number of code page. |
Columns
List of inserted columns.
Declaration
public MsAccessBulkInsertColumnCollection Columns { get; }
Property Value
Type | Description |
---|---|
MsAccessBulkInsertColumnCollection | List of columns as MsAccessBulkInsertColumnCollection. |
Remarks
Columns in the list must be in the same order as they are in input CSV file.
DestinationTableName
Destination table name in database.
Declaration
public string DestinationTableName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ExternalTransaction
External transaction, in which bulk insert is executed.
Declaration
public OleDbTransaction ExternalTransaction { get; }
Property Value
Type | Description |
---|---|
System.Data.OleDb.OleDbTransaction |
ValueDelimiter
Value separator in generated CSV file.
Declaration
public char ValueDelimiter { get; }
Property Value
Type | Description |
---|---|
System.Char |
Methods
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Insert(IBulkActionDataReader)
Declaration
public void Insert(IBulkActionDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
IBulkActionDataReader | reader |
Insert(DataTable)
Declaration
public void Insert(DataTable table)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | table |
Insert(IDataReader)
Declaration
public void Insert(IDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDataReader | reader |
InsertAsync(IBulkActionDataReader)
Declaration
public Task InsertAsync(IBulkActionDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
IBulkActionDataReader | reader |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
InsertAsync(DataTable)
Declaration
public Task InsertAsync(DataTable table)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | table |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
InsertAsync(IDataReader)
Declaration
public Task InsertAsync(IDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDataReader | reader |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |