Hi there guys...

Been working all week for the database connection of VC# with SQLite. I got an error everytime i try to open the database... No matter how i tried the SQLiteConnection.Open() command still returns an error...

I installed the required ADO.NET and the required SQLite Database...

here's a sample code

using System.Data;
using System.Data.SQLite;
/*other using goes here*/

// here's a portion for the connection
 private void SetConnection()
        {
            try{
                sql_con = new SQLiteConnection
                    ("Data Source=C:/Users/Jessie/Documents/Visual Studio 2008/Projects/Face/DAT/DTR_DB.s3db;Version=3;New=False;Compress=True;");
                MessageBox.Show("Database Loading Successfull", "Database Load");
                sql_con.Open();  //THE ERROR GOES HERE
                MessageBox.Show("Database Opening Successfull", "Database Open");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Database Error");
            }

        }

that's the code Im using for my trial and error in connecting to SQLite... That's not the actual code I'm using for my program...

Kindly help me...
Im running VC# 2008 Express Edition in Windows 7 Ultimate...

Thanks in advance...

Try this code. I modified your path construction to use backslash and added exception handling to provide specific error information.

string database = @"C:\Users\Jessie\Documents\Visual Studio 2008\Projects\Face\DAT\DTR_DB.s3db";
            string connParams = @"Data Source={0};Version=3;New=False;Compress=True;";
            string connStr = string.Format(connParams, database);
            SQLiteConnection conn = new SQLiteConnection(connStr);

            try
            {
                conn.Open();
            }
            catch (SQLiteException ex)
            {
                Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
                System.Diagnostics.Debugger.Break();
            }
            finally
            {
                conn.Close();
            }

Nope, it didn't work as well... (T-T)

Nope, it didn't work as well... (T-T)

What is the error you are getting?

What is the error you are getting?

the error is

System.Data.SQLite.SQLiteException: File open is not a database file file is encrypted or not a database ...

the error is

System.Data.SQLite.SQLiteException: File open is not a database file file is encrypted or not a database ...

I thought I already replied to this... It sounds like you might have a compatibility issue between the DB and the client data provider. If you think this might be the case, you should verify the versions are compatible.

I thought I already replied to this... It sounds like you might have a compatibility issue between the DB and the client data provider. If you think this might be the case, you should verify the versions are compatible.

How can i verify it??? I'm new to VC#...

Hey there DoubleD, i just resolved the problem... it was really the file itself that has the problem... it was locked by the GUI i used to create it... i just imported the database as a SQLite file and presto... it worked... thanks for your effort to help... I really appreciate it... thanks!!! God Bless...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.