Class CsvDataConnection
Represents a connection to csv file-based database.
Inherited Members
Namespace: FastReport.Data
Assembly: FastReport.OpenSource.dll
Syntax
public class CsvDataConnection : DataConnectionBase, IFRSerializable, IParent
Examples
This example shows how to add a new connection to the report.
Report report1;
CsvDataConnection conn = new CsvDataConnection();
conn.CsvFile = @"c:\data.csv";
report1.Dictionary.Connections.Add(conn);
conn.CreateAllTables();
Constructors
CsvDataConnection()
Initializes a new instance of the CsvDataConnection class.
Declaration
public CsvDataConnection()
Fields
DEFAULT_FIELD_NAME
The default field name.
Declaration
public const string DEFAULT_FIELD_NAME = "Field"
Field Value
| Type | Description |
|---|---|
| System.String |
Properties
Codepage
Gets or sets the codepage of the .csv file.
Declaration
public int Codepage { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ConvertFieldTypes
Gets or sets the value indicating that field types fhould be converted.
Declaration
public bool ConvertFieldTypes { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
CsvFile
Gets or sets the path to .csv file.
Declaration
public string CsvFile { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
FieldNamesInFirstString
Gets or sets the value indicating that field names should be loaded from the first string of the file.
Declaration
public bool FieldNamesInFirstString { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
RemoveQuotationMarks
Gets or sets the value indicating that quotation marks should be removed.
Declaration
public bool RemoveQuotationMarks { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Separator
Gets or sets the separator of the .csv file.
Declaration
public string Separator { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
CreateDataSet()
Initializes a DataSet instance.
Declaration
protected override DataSet CreateDataSet()
Returns
| Type | Description |
|---|---|
| DataSet | The DataSet object. |
Overrides
Remarks
This method is used to support FastReport infrastructure. You don't need to use it.
CreateTable(TableDataSource)
Creates table. For internal use only.
Declaration
public override void CreateTable(TableDataSource source)
Parameters
| Type | Name | Description |
|---|---|---|
| TableDataSource | source |
Overrides
DeleteTable(TableDataSource)
Deletes table. For internal use only.
Declaration
public override void DeleteTable(TableDataSource source)
Parameters
| Type | Name | Description |
|---|---|---|
| TableDataSource | source |
Overrides
FillTableData(DataTable, String, CommandParameterCollection)
Fills the table data.
Declaration
public override void FillTableData(DataTable table, string selectCommand, CommandParameterCollection parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| DataTable | table | DataTable to fill. |
| System.String | selectCommand | The SQL select command. |
| CommandParameterCollection | parameters | SQL parameters. |
Overrides
Remarks
Usually you don't need to use this method. Internally it uses the GetConnection() and GetAdapter(String, DbConnection, CommandParameterCollection) methods to fill the table data. If you create own connection component that does not use nor connection or adapter, then you need to override this method.
FillTableSchema(DataTable, String, CommandParameterCollection)
Fills the table schema.
Declaration
public override void FillTableSchema(DataTable table, string selectCommand, CommandParameterCollection parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| DataTable | table | DataTable to fill. |
| System.String | selectCommand | The SQL select command. |
| CommandParameterCollection | parameters | SQL parameters. |
Overrides
Remarks
Usually you don't need to use this method. Internally it uses the GetConnection() and GetAdapter(String, DbConnection, CommandParameterCollection) methods to fill the table schema. If you create own connection component that does not use nor connection or adapter, then you need to override this method.
QuoteIdentifier(String, DbConnection)
Quotes the specified DB identifier such as table name or column name.
Declaration
public override string QuoteIdentifier(string value, DbConnection connection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | Identifier to quote. |
| DbConnection | connection | The opened DB connection. |
Returns
| Type | Description |
|---|---|
| System.String | The quoted identifier. |
Overrides
SetConnectionString(String)
Sets the connection string.
Declaration
protected override void SetConnectionString(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | New connection string. |
Overrides
Remarks
Use this method if you need to perform some actions when the connection string is set.