Passing Connection String

In some cases you may want to pass the DB connection string as a constructor parameter of the <DatabaseName> class. To do that open the <DatabaseName>.cs or <DatabaseName>.vb file and make the following modifications:

C#:
private string _connection;

public MyDb(string connection) : base(false)
{
    _connection = connection;
    InitConnection();
}

protected override IDbConnection CreateConnection()
{
    return new System.Data.OleDb.OleDbConnection(_connection);
}

VB.NET:
Private _connection As String

Public Sub New
(connection As String)
    MyBase.New(False)
    _connection = connection
    InitConnection()
End Sub

Protected Overrides Function CreateConnection() As IDbConnection
    Return New System.Data.OleDb.OleDbConnection(_connection)
End Function