I'm trying to build a valid connection string with the SQLiteConnectionStringBuilder (System.Data.SQLite v1.0.88.0) using either the datasource or the URI:
Dim connectionBuilder = New SQLiteConnectionStringBuilder
connectionBuilder.DataSource = Path.Combine(datadir, "mydatabase.sqlite")
connectionBuilder.Version = 3
' Open connection
Dim connection As New SQLiteConnection(connectionBuilder.ConnectionString)
Or:
Dim connectionBuilder = New SQLiteConnectionStringBuilder
connectionBuilder.Uri = New Uri(Path.Combine(datadir, "mydatabase.sqlite")).AbsolutePath
connectionBuilder.Version = 3
' Open connection
Dim connection As New SQLiteConnection(connectionBuilder.ConnectionString)
Both generate the same connection string:
uri=file:///C:/Users/myusername/Documents/Visual%20Studio%202010/Projects/myproject/myproject/bin/Debug/data/mydatabase.sqlite;version=3
The URI itself is valid, the connection string actually looks good, but when I try to open the connection, it generates a NotSupportedException
due to the path format within SQLite:
bei System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
bei System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
bei System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
bei System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
bei System.IO.Path.GetFullPath(String path)
bei System.Data.SQLite.SQLiteConnection.ExpandFileName(String sourceFile, Boolean toFullPath) in c:\dev\sqlite\dotnet\System.Data. SQLite\SQLiteConnection.cs:Zeile 2690.
bei System.Data.SQLite.SQLiteConnection.Open() in c:\dev\sqlite\dotnet\System.Data.SQLite\SQLiteConnection.cs:Zeile 2009.
How can I prevent this short of building the connection string myself?