private void SetConnection()
{
string a = string.Format(@"Data Source={0};Version=3;New=False;Compress=True;", "~/lodeDb.db");
sql_con = new SQLiteConnection(a);
}
private void ExecuteQuery(string txtQuery)
{
SetConnection();
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
sql_cmd.CommandText = txtQuery;
sql_cmd.ExecuteNonQuery();
sql_con.Close();
}
When i run to sql_cmd.ExecuteNonQuery, Sqlexception is "Unable to open the database file". "lodeDb.db" file on my online hosting, i think data source is wrong. Can U tell me if db file in online hosting. How to set datasourse for connection Thanks you Note: Permission file is no problem in here
Since its inception on 2000-05-29, SQLite has been implemented in generic C. C was and continues to be the best language for implementing a software library like SQLite. There are no plans to recode SQLite in any other programming language at this time.
Getting Started with SQLite from a . Open Visual Studio, select new project, and, in Visual C#, select “Console Application” and provide the name as SQLiteDemo. Click OK. To connect SQLite with C#, we need drivers. Install all required SQLite resources from the NuGet package, as pictured in Figure 1.
MySQL has a well-constructed user management system which can handle multiple users and grant various levels of permission. SQLite is suitable for smaller databases. As the database grows the memory requirement also gets larger while using SQLite. Performance optimization is harder when using SQLite.
SQLite vs SQL (Comparison) The main difference between them is that SQL stands for Structured Query Language, which is the query language used with databases. But SQLite is a portable database. Extensions can be added to the computer language used to access the database.
I got the same exception when trying to open databases that are on the network drive (path starts with "\\myServer\myDbFile...") and I resolved it by putting true
to the parseViaFramework
parameter in connection constructor.
sql_con = new SQLiteConnection(a, true);
It's a Connection String Issue,
SQL Lite Connection Strings Formats
Basic :
Data Source=filename;Version=3;
Using UTF16 :
Data Source=filename;Version=3;UseUTF16Encoding=True;
With password :
Data Source=filename;Version=3;Password=myPassword;
Using the pre 3.3x database format :
Data Source=filename;Version=3;Legacy Format=True;
With connection pooling :
Data Source=filename;Version=3;Pooling=False;Max Pool Size=100;
Read only connection :
Data Source=filename;Version=3;Read Only=True;
EDIT 1 :
Connecting to remote database differs, you must check the following.
My problem is solved when add "Journal Mode=Off;" in connection string
Disable the Journal File This one disables the rollback journal entirely.
Data Source=c:\mydb.db;Version=3;Journal Mode=Off;
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