Yuvraj Jambhle

Yuvraj Jambhle

  • NA
  • 93
  • 8.4k

How to create dynamic connection string for SQLite database in C#

Jul 12 2021 8:24 AM

Hello,

I have a static connection string for SQLlite DB connectivity. 

 string hmiDbCon = @"Data Source= C:\Users\user\Desktop\ReportTmplate\Database.db; version=3"; 

But I want to read SQLite DB file from any location. I got file location and file name using this below code.

string dbPath = Path.GetFullPath(dbSelect.FileName);

Now question is how can I create dynamic connection string.

Please suggest me how can I use that string dbPath in above mentioned string.


Answers (2)