OskarS
OskarS

Reputation: 65

SQLite Can't connect to database on another PC

I have some issues with my SQLite database. When I'm making an app in WPF(VS2015) on my personal computer and I'm debugging a program, the whole database is working fine(no errors). But when I'm trying to run an .exe file on any other PC (I'm copying the whole debug folder with the database file in it) my application can't connect to database and it crashes.

            string dbConnection = @"Data Source=db2.db; Version=3;";
            SQLiteConnection sqliteCon = new SQLiteConnection(dbConnection);


        try
        {
            sqliteCon.Open();
            string Query = "select * from Haslo where Haslo = '" + this.passwordBox.Password + "' ";
            SQLiteCommand createCommand = new SQLiteCommand(Query, sqliteCon);

            createCommand.ExecuteNonQuery();
            SQLiteDataReader dr = createCommand.ExecuteReader();

It looks like it can't even connect to database file, beacause I left only this fragment and application stops here.

string dbConnection = @"Data Source=db2.db; Version=3;";
SQLiteConnection sqliteCon = new SQLiteConnection(dbConnection);

I tried also to use "try and catch" here but nothing happend. After few seconds there is only MessageBox "Application stop running".

I also made a second database and this problem remained.

It's obvious that my PC have something that rest of computers haven not. I made database in mozilla addon "SQLite Menager". I'm new in proggraming so thanks for your patience. Any clues ?

Upvotes: 1

Views: 1805

Answers (2)

sparrow
sparrow

Reputation: 980

How did you install the SQLite DLLs on the first machine? If you installed them using the executable then they are probably in the GAC and that's why you can open it on the first machine but when you copy to the second machine, it doesn't have the DLLs.

You can use the SQLite nuget package which will put all the necessary DLLs into your projects output folder so you can copy it to somewhere else.

Upvotes: 2

S. Cassidy
S. Cassidy

Reputation: 61

So the problem is that you can't get other computers to connect to the database on your computer? When I had this issue a while ago, it was because the firewall my computer was behind masked the ip so computers outside the firewall wouldn't recognize it.

Upvotes: 0

Related Questions