SQLiteConnectionStringBuilder not working as advertised
Posted: Tue 25 Jan 2011 18:28
In the Devart sqlite documentation to build a SQLiteConnectionStringBuilder object it states:- Use the following.
SQLiteConnectionStringBuilder connSB = new SQLiteConnectionStringBuilder();
connSB.DataSource = @"Data Source=D:\TestApplication\database.db;FailIfMissing=False;";
connSB.FailIfMissing = false;
connSB.Locking = LockingMode.Exclusive;
connSB.AutoVacuum = AutoVacuumMode.Full;
connSB.ConnectionTimeout = 20;
SQLiteConnection sqLiteConnection1 = new SQLiteConnection(connSB.ConnectionString);
Its excepts with "Path is not of the correct format" when I replace D:\TestApplication\database.db with C:\Rufus.db. An examination of the connection found two DataSource string entries in. So I thought, mistake in the docs.
So changed it to the following, losing the DataSource bit.
ConnectionBuild = new SQLiteConnectionStringBuilder();
ConnectionBuild.DataSource = @"C:\Rufus.db;FailIfMissing=true;";
ConnectionBuild.Locking = LockingMode.Normal;
ConnectionBuild.AutoVacuum = AutoVacuumMode.Full;
ConnectionBuild.ConnectionTimeout = 20;
Connection = new SQLiteConnection(ConnectionBuild.ConnectionString);
with a precreated Rufus.db, and FailIfMissing=true, it excepts with {"SQLite error\r\nno such table: IDMEF"} from a SQLiteException. Different exception.
However, when I use a simple connection string such as
Connection = new SQLiteConnection();
Connection.ConnectionString = @"Data Source=C:\Rufus.db;FailIfMissing=true;";
it inserts into the IDMEF table, no problem.
So is their something wrong with either SQLiteConnectionStringBuilder object creating the connection string, or the docs wrong or am i create the wrong connection string.
Thanks for your help.
SQLiteConnectionStringBuilder connSB = new SQLiteConnectionStringBuilder();
connSB.DataSource = @"Data Source=D:\TestApplication\database.db;FailIfMissing=False;";
connSB.FailIfMissing = false;
connSB.Locking = LockingMode.Exclusive;
connSB.AutoVacuum = AutoVacuumMode.Full;
connSB.ConnectionTimeout = 20;
SQLiteConnection sqLiteConnection1 = new SQLiteConnection(connSB.ConnectionString);
Its excepts with "Path is not of the correct format" when I replace D:\TestApplication\database.db with C:\Rufus.db. An examination of the connection found two DataSource string entries in. So I thought, mistake in the docs.
So changed it to the following, losing the DataSource bit.
ConnectionBuild = new SQLiteConnectionStringBuilder();
ConnectionBuild.DataSource = @"C:\Rufus.db;FailIfMissing=true;";
ConnectionBuild.Locking = LockingMode.Normal;
ConnectionBuild.AutoVacuum = AutoVacuumMode.Full;
ConnectionBuild.ConnectionTimeout = 20;
Connection = new SQLiteConnection(ConnectionBuild.ConnectionString);
with a precreated Rufus.db, and FailIfMissing=true, it excepts with {"SQLite error\r\nno such table: IDMEF"} from a SQLiteException. Different exception.
However, when I use a simple connection string such as
Connection = new SQLiteConnection();
Connection.ConnectionString = @"Data Source=C:\Rufus.db;FailIfMissing=true;";
it inserts into the IDMEF table, no problem.
So is their something wrong with either SQLiteConnectionStringBuilder object creating the connection string, or the docs wrong or am i create the wrong connection string.
Thanks for your help.