Class OdbcDataConnection
Represents a connection to any database through ODBC.
Inheritance
Inherited Members
Namespace: FastReport.Data
Assembly: FastReport.dll
Syntax
public class OdbcDataConnection : DataConnectionBase, IComponent, IDisposable, IFRSerializable, IHasEditor, IParent
Examples
This example shows how to add a new connection to the report.
Report report1;
OdbcDataConnection conn = new OdbcDataConnection();
conn.ConnectionString = "your_connection_string";
report1.Dictionary.Connections.Add(conn);
conn.CreateAllTables();
Methods
GetAdapter(String, DbConnection, CommandParameterCollection)
Returns a System.Data.Common.DbDataAdapter object that is specific to this connection.
Declaration
public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection, CommandParameterCollection parameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | selectCommand | The SQL command used to fetch a table data rows. |
System.Data.Common.DbConnection | connection | The connection object. |
CommandParameterCollection | parameters | The select command parameters. |
Returns
Type | Description |
---|---|
System.Data.Common.DbDataAdapter | The DbDataAdapter object. |
Overrides
Remarks
You should override this method if you are developing a new connection component. In this method, you need to create the adapter and set its SelectCommand's parameters.
If your connection does not use data adapter, you need to override the FastReport.Data.DataConnectionBase.FillTableSchema(System.Data.DataTable, System.String, FastReport.Data.CommandParameterCollection) and FastReport.Data.DataConnectionBase.FillTableData(System.Data.DataTable, System.String, FastReport.Data.CommandParameterCollection) methods instead.
GetConnectionId()
Gets a string that will identify a connection in the Data Wizard.
Declaration
public override string GetConnectionId()
Returns
Type | Description |
---|---|
System.String | The string that contains the connection type and some meaningful information. |
Overrides
GetConnectionStringWithLoginInfo(String, String)
Gets a connection string that contains username and password specified.
Declaration
protected override string GetConnectionStringWithLoginInfo(string userName, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | userName | User name. |
System.String | password | Password. |
Returns
Type | Description |
---|---|
System.String |
Overrides
Remarks
Override this method to pass login information to the connection. Typical implementation must get the existing ConnectionString, merge specified login information into it and return the new value.
GetConnectionType()
Returns a type of connection.
Declaration
public override Type GetConnectionType()
Returns
Type | Description |
---|---|
System.Type | Type instance. |
Overrides
Remarks
You should override this method if you developing a new connection component.
If your connection component does not use data connection, you need to override the FillTableSchema(DataTable, String, CommandParameterCollection) and FillTableData(DataTable, String, CommandParameterCollection) methods instead.
GetDefaultParameterType()
Gets the default type for a new parameter.
Declaration
public override int GetDefaultParameterType()
Returns
Type | Description |
---|---|
System.Int32 | The integer representation of a parameter type. |
Overrides
GetEditor()
Gets a control that will be used to edit the connection properties.
Declaration
public override ConnectionEditorBase GetEditor()
Returns
Type | Description |
---|---|
ConnectionEditorBase | The editor's control. |
Overrides
GetParameterType()
Gets the type of parameter that is specific to this connection.
Declaration
public override Type GetParameterType()
Returns
Type | Description |
---|---|
System.Type | The parameter's type. |
Overrides
Remarks
This property is used in the report designer to display available data types when you edit the connection parameters. For example, the type of OleDbConnection parameter is a OleDbType.
GetTableNames()
Gets an array of table names available in the database.
Declaration
public override string[] GetTableNames()
Returns
Type | Description |
---|---|
System.String[] | An array of strings. |
Overrides
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. |
System.Data.Common.DbConnection | connection | The opened DB connection. |
Returns
Type | Description |
---|---|
System.String | The quoted identifier. |