Search code examples
vb.netsqlitesqlite-net

SQLite database file can't be opened when placed in network folder


Can someone help me to understand why this works fine...

Dim cs = "Data Source=C:\folder\Livros.sdb;Version=3;"
Dim cn = New System.Data.SQLite.SQLiteConnection(cs)
cn.Open() ' no exception 

... while this breaks when opening connection (it is exactly the same file)...

Dim cs = "Data Source=\\NetworkServer\folder\Livros.sdb;Version=3;"
Dim cn = New System.Data.SQLite.SQLiteConnection(cs)
cn.Open() ' exception: {"unable to open database file"}

... and fix it because I need to place database file in network location so I can access it regardless of the computer I run the application?

Thank you very much!


Solution

  • Ok, so by trial and error I found the solution, although I can't quite understand the reason it works:

    Dim cs = "Data Source=\\NetworkServer\folder\Livros.sdb;Version=3;"
    Dim cn = New System.Data.SQLite.SQLiteConnection(cs)
    cn.ParseViaFramework = True ' JUST ADDED THIS STATEMENT
    cn.Open() ' no exception
    

    If somebody can explain why .ParseViaFramework = True does the trick, please feel free to comment.