Knight Data Access Layer
Open Close Wrapper VB.NET
Basic Tasks VB.NET > Patterns > Open Close Wrapper VB.NET

To ensure the connection is closed after a set of operations, use the OpenCloseWrapper.

 

'New up the provider for what database we will be interacting with

Dim provider As New SqLiteProvider()

 

'Build the connection string

Dim builder As New SQLiteConnectionStringBuilder()

builder.DataSource = _databaseFilePath

provider.ConnectionString = builder.ConnectionString

 

Dim db As New DataHelper(provider) 'This is trial mode

'Dim db = new DataHelper(provider,"User Name", "License Key") //This is the user name and license key on the receipt

 

'Log to the console

db.EnableLogging()

 

'Open the connection

Using TempOpenCloseWrapper As OpenCloseWrapper = New OpenCloseWrapper(db)

Console.WriteLine("Perform some database operation here")

End Using 'Connection closed during dispose