Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have windows application WPF. And installed in networked connected client machine. I want to access the SQLite db from admin machine that network connected. The DB located inside admin's c drive with 'qscanDBAttacheds' folder name. Here

C#
txtipaddress.Text = "100.85.138.330";
ip address.

What I have tried:

C#
private void Add_Click(object sender, RoutedEventArgs e)
       {
           myBuilder = new SQLiteConnectionStringBuilder()
           {
               DataSource = @"\\\\" + txtipaddress.Text + @"\qscanDBAttacheds\test.s3db;Version=3;New=False;Compress=True;"
           };

           SQLiteConnection con = new SQLiteConnection(myBuilder.ConnectionString);
           con.Open();
           MessageBox.Show("Success");
       }


But shown error "can not open database."

Please help me...
Posted
Updated 4-Jun-20 3:23am
v2

Sqlite is file-based only. There is no way to talk to it over TCP/IP.

Like an Access database file, you have to have the database file in a network shared folder. The path is usually going to be a UNC path, like "\\server\sharename\folderpath\databasefile".

The problem is the connection string you built isn't a connection string. It's a partial string. You have this:
DataSource = @"\\\\" + txtipaddress.Text + @"\qscanDBAttacheds\test.s3db;Version=3;New=False;Compress=True;"

The "DataSource" part has to be part of the string you build. You don't have that. You need this:
string connString = @"Data Source=\\" + txtipaddress.Text + @"\qscanDBAttacheds\test.s3db;Version=3;New=False;Compress=True;"
 
Share this answer
 
Comments
Rajesh Kumar 2013 20-Jan-17 23:55pm    
@Dave kreskowiak - Thank you for reply me. I have tried your advice. Then getting like connectionstring "Data Source=\\\\192.168.0.105\\qscanDBAttacheds\\test.s3db;Version=3;New=False;Compress=True;" But still it showing {"unable to open database file"} error. The db is inside another machine c drive is a path with 'qscanDBAttacheds' folder name but both are network connected. Please help me.
Rajesh Kumar 2013 21-Jan-17 0:43am    
I have already developed WPF windows app with SQLite db. Alternatively if its not possible in Sqlite i could migrate it in MySql. May I need a licence(paid) to distribute MySQL commercially ? I can not use paid one database. Actually, I wanted it to deploy on other machines without having to install mysql individually/saperately on each machine. Please suggest me ways...
Dave Kreskowiak 21-Jan-17 10:12am    
OK. SQLite is a desktop database, just like Access. It's not really made for multiuser environments.

In order to get this to work, you MUST understand Windows networking and sharing. Without that, you're going to find this take impossible.

Now, if you really want a bunch of users to use the same database, you have to move to a database engine that supports such, like MySQL or SQL Server. You don't have to understand file shares but you do have to understand TCP/IP networking.

In order to use one of those engines, you must install it on a server that all of your users machines can get to on the network.
Rajesh Kumar 2013 21-Jan-17 10:44am    
@Dave Kreskowiak Sir, please. It is a product, then every time need to install MSSQL or MYSQL each admin's machine. How... how its possible? Please help me... I am in big trouble. OR anyway, Can I deploy on admin's machines without having to install mysql individually/saperately on each machine. Please suggest me ways.
Dave Kreskowiak 21-Jan-17 10:53am    
The problem here is that you have no idea what you're doing with a database and you don't understand what I'm telling you.

Now, what are your applications requirements? Do you have to install the database on the same machine as the application or not? Or are you trying to have multiple instances of your application all work with the exact same copy of the database?
In windows, instead of using "\" as file separator use "/".
 
Share this answer
 
Comments
tweber2012 25-Sep-18 9:50am    
@hansoctantan I love you!!!!!!!!!!!!!
hansoctantan 29-Oct-18 22:13pm    
love you too.. xD
Member 12594087 28-Jan-19 7:28am    
Hat off!@hansoctantan. You saved my life.
Member 14128757 19-Nov-19 14:41pm    
Thanks!
Use like this:

"Data Source=\\\\Test-PC\Db\MyDb.db"

Test-PC is network device
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900