Firebird ADO.NET Provider SDK Documentation - v1.7

FbConnection Class

Represents an open connection to a Firebird database. This class cannot be inherited.

For a list of all members of this type, see FbConnection Members.

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         FirebirdSql.Data.Firebird.FbConnection

[Visual Basic]
<ToolboxBitmap, _  DefaultEvent(Name:="InfoMessage"), _  ToolboxItem(ToolboxItemType:=System.Drawing.Design.ToolboxItem, ToolboxItemTypeName:="System.Drawing.Design.ToolboxItem, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), _  DesignerCategory(Category:="Component")>
NotInheritable Public Class FbConnection
    Inherits Component
    Implements IDbConnection, ICloneable
[C#]
[ToolboxBitmap]
[DefaultEvent(Name="InfoMessage")]
[ToolboxItem(ToolboxItemType=System.Drawing.Design.ToolboxItem, ToolboxItemTypeName="System.Drawing.Design.ToolboxItem, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[DesignerCategory(Category="Component")]
public sealed class FbConnection : Component, IDbConnection, ICloneable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

A FbConnection object represents a individual connection to Firebird server.

If a FbConnection object goes out of scope, it is not closed, you must explicitly close the the connection by calling Close or Dispose.

Example

public void InsertRow(string connectionString)
{
    //    If the connection string is null, use a default.
    if(connectionString == "")
    {
        FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
        
        cs.DataSource = "localhost";
        cs.Database = "C:\\PROGRAM FILES\\FIREBIRD\\EXAMPLES\\EMPLOYEE.FDB";
        cs.UserID = "SYSDBA";
        cs.Password = "masterkey";
        cs.Dialect = 3;
        
        connectionString = cs.ToString();
    }
    
    FbConnection connection = new FbConnection(connectionString);                    
    connection.Open();                    
    FbTransaction transaction = connection.BeginTransaction();
    
    string insertQuery = "INSERT INTO PROJECT(proj_id, proj_name, product) Values('FBNP', '.NET Provider', 'N/A')";
    FbCommand command = new FbCommand(insertQuery, myConn, myTxn);    
    
    command.ExecuteNonQuery();
    
    transaction.Commit();
    
    connection.Close();
}
                

Requirements

Namespace: FirebirdSql.Data.Firebird

Assembly: FirebirdSql.Data.Firebird (in FirebirdSql.Data.Firebird.dll)

See Also

FbConnection Members | FirebirdSql.Data.Firebird Namespace