1

I have C#.NET Web Application that Data Access Layer's dll referencing in WPF Windows application. This DAL, establishing a connection to SQLite.

I want to install WPF application on any other local machine. But the SQL database is located my computer folder like this:

  static SQLiteConnection dbConnection = new SQLiteConnection(@"Data Source=E:\File\DMS\DAL\Model\test.s3db;");

How can I do this?

lashja
  • 493
  • 10
  • 21

2 Answers2

3

Do you mean to get the application current dir? if that,you can get it like this.

var appDir = Environment.CurrentDirectory;
var appDir2 = AppDomain.CurrentDomain.BaseDirectory;

string myDir = @"File\DMS\DAL\Model\test.s3db";
var dir = System.IO.Path.Combine(appDir,myDir);
chengzi
  • 170
  • 2
  • 10
  • 1
    if you mean `sqlite-connecting-to-remote-file-using-url-c-sharp` , sqlite can not do this. You can see it here http://stackoverflow.com/questions/15612452/sqlite-connecting-to-remote-file-using-url-c-sharp – chengzi Nov 04 '16 at 14:24
2

You can share the file "E:\File\DMS\DAL\Model\test.s3db;" to be reachable from your network and then change your connection string to something like this "\\192.168.1.100\Model\test.s3db;" (Using IP) or this "\\MachineName\Model\test.s3db;".

Warning: You should set the necessary permissions to read/write in order to give access to the other machine and at the same time protect your file.

IMCI
  • 71
  • 5
  • I have 2 .exe wpf windows application. One is for client machine and 2nd is Admin machine. And these machines are under common network. With respect to your advice, I am planing to populate, a ask window for adding client's IP address after installation client .exe . Then add the ip to the sqlliteconnectionstring by using SQLiteConnectionStringBuilder class. Is this approach good or bag? – lashja Jan 19 '17 at 17:23