Knight Data Access Layer
Connection String Tags
Basic Tasks VB.NET > Connection Strings > Connection String Tags

The .NET Data Access Layer supports special directories for file based databases. 

 

Tag Replacement Note

%CurrentDirectory%

AppDomain.CurrentDomain.BaseDirectory

https://msdn.microsoft.com/en-us/library/system.appdomain.basedirectory%28v=vs.110%29.aspx

|DataDirectory|

AppDomain.CurrentDomain.GetData("DataDirectory")

http://stackoverflow.com/questions/1409358/ado-net-datadirectory-where-is-this-documented

%ApplicationData%

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx

%CommonApplicationData%

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

%LocalApplicationData%

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

%MyDocuments%

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

%CurrentDriveLetter%

The drive letter for 

AppDomain.CurrentDomain.BaseDirectory

 

Example Usage

 

'Setup the provider

Dim provider As New SqLiteProvider()

provider.ConnectionString = "Data Source=%LocalApplicationData%\mydb.db;Version=3;"

 

'Manually instantiate a session

Dim db As New DataHelper(provider)