2011/09/22

[C#] Firebird 연결문자열을 FbConnectionStringBuilder를 이용하여 만들기

Connection Strings을 아래와 같이 문자열로 작업하는 것이 아니라 FbConnectionStringBuilder 객체를 이용하면 좀 더 쉽고 직관적으로 만들 수 있다.

string connectionString =
"User=SYSDBA;" +
"Password=masterkey;" +
"Database=F:\FirebirdDB\ estdb.fdb;" +
"DataSource=localhost;" +
"Charset=UTF8;" +
"ServerType=0"; // Type: 0 - Server, 1 - Embedded



FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.UserID = "SYSDBA";
csb.Password = "masterkey";
csb.Database = "F:\FirebirdDB\ estdb.fdb";
csb.DataSource = "localhost";
csb.Charset = "UTF8";
csb.ServerType = FbServerType.Default;

// Create Database
FbConnection.CreateDatabase(csb.ToString());

// Create Connection object
FbConnection conFirebird = new FbConnection(csb.ToString());

:

// Drop Database
FbConnection.DropDatabase(csb.ToString());



FbConnectionStringBuilder Properties (출처: Firebird .Net Provider SDK 1.7 문서)





















































































































NameTypeDescription
CharsetstringGets or sets the connection character set.
ClientLibrarystring

ConnectionLifeTimeintGets or sets the lifetime of a connection in the pool.
ConnectionTimeoutintGets the time to wait while trying to establish a connection before terminating
the attempt and generating an error.
ContextConnectionbool

DatabasestringGets the name of the actual database or the database to be used when a
connection is open.
DataSourcestringGets the name of the Firebird Server to which to connect.
DbCachePagesint

DialectintGets or sets the database dialect.
Enlistbool

FetchSizeintIndicates the number of rows that will be fetched at the same time on Read calls into the internal row buffer.
IsolationLevelIsolationLevel Gets or sets the default Isolation Leve for implicit transactions.
MaxPoolSizeintGets or sets the maximun pool size.
MinPoolSizeintGets or sets the minumun pool size.
PacketSizeintGets or sets the size (in bytes) of network packets used to communicate with an
instance of Firebird Server.
PasswordstringGets ort sets the password for the Firebird user account.
PoolingboolGets or sets the status of the connection pooling.
PortintGets or sets the port number in the server for establish the connection.
ReturnRecordsAffected bool

RolestringGets or sets the suer role name.
ServerTypeFbServerType Gets or sets the server type to wich we want to connect.
UserIDstringGets or sets the firebird User account for login.



<

Original Post : http://neodreamer-dev.tistory.com/580

No comments :

Post a Comment