Message 1 of 6
Create and Connect to SQLite Database (DB) in C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
As the title suggests I need to create and connect to a SQL DB to start. I know there are many specific forums for it but I am here because I have gotten it to fully work in the Revit context via Python but having difficulty translating it to C# in context to the Revit API.
I can create a new db by:
string filePath = @"C:\Users\User\Desktop\Test.db";
SQLiteConnection.CreateFile(filePath);
But when I try to open the connection, it does not work. (Code just terminates/fails).
string ds = "Data Source=" + filePath + ";Version=3;";
SQLiteConnection c = new SQLiteConnection(ds);
c.Open();
I've tried many configurations, such as:
- placing the code in a try/catch block
- formatting the ds string different ways
- writing the connection line with a using statement
but they all fail. This should be the simplest step but it appears I am missing something. Can anyone who has gotten SQLite connections to work via C# shed any light to this? Thank you.