Hey all, I've been using System.Data.SQLite in a project for several months now and have to say that I love it! It always works great. But just yesterday I've run accross a really strange incompatibillity that I can't seem to figure out.
I use SQLite several times throught my program to write values to a log file and a settings file. This always works as expected until I try and run the same code after I've made a call to a slick little MAPI32 wrapper that Andrew Baker wrote here:
http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=71&PostID=1
After I've called his MapiMailMessage.ShowDialog(), the very next time I try and call any code for reading or writing to a database I get a table not found error.
Here's a sample of one of the interactions with SQLite that I'm using:
(This is written in C# by the way)
private void setValueInDataBase(SettingsClient key, String value)
{
// Get the connection string for the database file
String connectionString = SharedDAO.CreateSQLiteConnectionString(SettingsDBName);
// Create the SQLite Connection
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
// Open the connection
conn.Open();
// Create the transaction
using (SQLiteTransaction trans = conn.BeginTransaction())
{
// Create the SQLite Command
using (SQLiteCommand command = new SQLiteCommand(conn))
{
// Declare our query
command.CommandText = @"UPDATE client_settings
SET
Value = @value
WHERE
Key = @key";
// Add the parameter
command.Parameters.Add(new SQLiteParameter("@key", (int)key));
command.Parameters.Add(new SQLiteParameter("@value", value));
// Execute the query
try
{
command.ExecuteNonQuery();
}
catch (Exception exc)
{
//throw;
Console.WriteLine(exc.ToString());
}
}
// Commit the transaction
trans.Commit();
}
}
}
I've been able to verify by a process of elimination that the actual code that determines whether an exception will be thrown is the line in Andrew's code that makes the call to the MAPI32.dll, namely:
int error = MAPIHelperInterop.MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, MAPI_DIALOG | MAPI_NEW_SESSION, 0);
After this line, any time I attempt to interact with a SQLite table I get a table could not be found exception.
For the time being I'm looking for another way to create new emails and attach stuff to them. But it's kind of strange that this seemingly unrelated functionality would have an effect on my SQLite stuff.
Any help on this would be greatly appreciated!