I know that this may seem as a question that was already asked, but I tried the solutions out there already.
I am building a program with C# and I need to save data in a way that every client has his own fresh (dynamic path) to his db. What can I do so users won't need to install extra things, but just .NET framework?
I heard about SQLite, but I didn't really get it working.
Sql Server CE. It runs in-process and you can deploy all required assemblies with your application. See this article:
How to: Deploy a SQL Server Compact 3.5 Database with an Application
Update: Adding some other SQL Server CE related links that I have found helpful:
SQL Server Compact “Private Deployment” on desktop–an overview
Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)
Privately Deploying SQL Server Compact with the ADO.NET Entity Provider
Download the SQLite .NET data provider here and then reference System.Data.SQLite.dll from within your application. The following example should work right off the bat.
using (var connection = new SQLiteConnection("Data Source=yourfile.db;Version=3;"))
using (var command = connection.CreateCommand())
{
connection.Open();
command.CommandText = "select name from from sqlite_master";
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(Convert.String(reader["name"]));
}
}
}
Of course all it does is list the tables in the specified file. If the file does not exist then it will be created automatically and naturally there will not be any tables in it. But, at the very least it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With