Firebird ADO.NET provider supports a new class (FbConnectionStringBuilder) that makes the work with connection strings much easier:
1. Parsing a connection string
Create a new instance using public FbConnectionStringBuilder(string) constructor (it takes an existing connection string as a parameter). Then you can read the connection string values by using the FbConnectionStringBuilder properties. Example of reading the DataSource (server address) property:
FbConnectionStringBuilder csb = new FbConnectionStringBuilder("User=SYSDBA;Password=masterkey;Database=SampleDatabase.fdb;DataSource=localhost;Charset=NONE;");
Console.WriteLine(csb.DataSource);
2. Creating a connection string programmatically
You can create a connection string by specifying the properties item by item:
FbConnectionStringBuilder csb = new FbConnectionString();
csb.UserID = "SYSDBA";
csb.Password = "masterkey";
csb.Database = "mydb.fdb";
csb.ServerType = 1; // embedded Firebird
FbConnection c = new FbConnection(csb.ToString());
3. Modifying an existing connection string
You can also modify an existing connection string without complicated parsing. This example switches the type of server to embedded Firebird:
FbConnectionStringBuilder csb = new FbConnectionString(existingConnectionString);
csb.ServerType = 1;
FbConnection c = new FbConnection(csb.ToString());
FbConnectionStringBuilder Properties Overview
| FbConnectionStringBuilder Property |
Type |
Description |
| ConnectionLifeTime |
System.Int64 |
When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime. |
| ConnectionString |
System.String |
Here you can get or set the entire connection string. |
| ConnectionTimeout |
System.Int32 |
The time to wait while trying to establish a connection before terminating the attempt and generating an error. |
| Database |
System.String |
The database path to establish the connection. Can be relative to the server executable or fbembed.dll (embedded Firebird). |
| DataSource |
System.String |
The server name for establish the connection. |
| Dialect |
System.Byte |
Database dialect (1 or 3). Use 3 unless you want specifically use dialect 1 for backwards compatiblity. |
| FetchSize |
System.Int32 |
Indicates the number of rows that will be fetched at the same time on Read calls into the internal row buffer. |
| Charset |
System.String |
Connection character set. |
| IsolationLevel |
System.Data.IsolationLevel |
The maximum number of connections allowed in the pool. |
| MaxPoolSize |
System.Int32 |
The maximun pool size. |
| MinPoolSize |
System.Int32 |
The minimum number of connections allowed in the pool. |
| PacketSize |
System.Int16 |
The size (in bytes) of network packets used to communicate with an instance of Firebird Server. |
| Password |
System.String |
The password for the Firebird user account. |
| Pooling |
System.Boolean |
When true, the FbConnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. |
| Port |
System.Int32 |
The port number in the server for establish the connection |
| Role |
System.String |
The user role name. |
| ServerType |
System.Int32 |
When 0 the provider will use the GDS implementation used for connections to Firebird Super or Classic servers, when 1 the provider will use the GDS implementation used for connections to the Firebird embedded server. |
| UserID |
System.String |
The firebird User account for login. |
See also
| Firebird Charset |
Description |
| ASCII |
American Standard Code for Information Interchange. |
| BIG_5 |
Big5, Traditional Chinese. |
| DOS437 |
MS-DOS United States, Australia, New Zealand, South Africa. |
| DOS850 |
MS-DOS Latin-1. |
| DOS860 |
MS-DOS Portugues. |
| DOS861 |
MS-DOS Icelandic. |
| DOS863 |
MS-DOS Canadian French. |
| DOS865 |
MS-DOS Nordic. |
| EUCJ_0208 |
JIS X 0201, 0208, 0212, EUC encoding, Japanese. |
| GB_2312 |
GB2312, EUC encoding, Simplified Chinese. |
| ISO8859_1 |
ISO 8859-1, Latin alphabet No. 1. |
| ISO8859_2 |
ISO 8859-2, Latin alphabet No. 2. |
| KSC_5601 |
Windows Korean. |
| ISO2022-JP |
Windows Japanese. |
| SJIS_0208 |
Japanese (Shift-JIS) |
| UNICODE_FSS |
Eight-bit Unicode Transformation Format. |
| WIN1250 |
Windows Eastern European. |
| WIN1251 |
Windows Cyrillic. |
| WIN1252 |
Windows Latin-1. |
| WIN1253 |
Windows Greek. |
| WIN1254 |
Windows Turkish. |
| WIN1254 |
Windows Hebrew. |
| Arabic |
Arabic. |
| WIN1257 |
Windows Baltic. |