Search code examples
c#sqlitefileserver

.db file on File-Server can't be used in a connection string


I'm trying to read a .db database file, that is in a Directory on a Server. When the file is on my Computer it can be opend with: connection.ConnectionString = "Data Source= " + dataSource; dataSource is the path to the file (@"C:\user...\data.db) Now i've put it on a File Server in my Company because multiple users will run the application with the database. (it is only a Programm for some trainees we have so no big official stuff here) When i try to fill a DataTable the error System.Data.SQLite.SQLiteException: "unable to open database file" Comes up.

I've tested the file i hand over with file.exists(dataSource) and it was there, so no misspelling here.

string dataSource = @"\\dc-it\IT\Misc proj\Pf_Test\data.db";

connection.ConnectionString = "Data Source= " + dataSource;

SQLiteDataAdapter mySQLiteDataAdapter = new SQLiteDataAdapter(selectCommand, connection);

mySQLiteDataAdapter.Fill(GridViewDataTable);

Solution

  • OK, i found the solution. I Simply have to give him:

    string dataSource = @".\data.db";
    

    then its working, at least on the Server. I don't know why he wont take the whole path. Bad for Debugging but working.