I've just fixed the Gentle.NET provider for SQLite, and have based the implementation on this library.
However, I had to fix two bugs in the current implementation. I'd like to submit these changes for inclusion in the main library - where can I send the modified source files?
FYI, the bugs were (a) database file was kept open if statement was invalid, and (b) ExecuteScalar did not return result from last statement when a batch was executed (e.g. insert + select rowid).
ExecuteScalar should return the first column of the first row of the first row-returning statement in the command, correct?
That's also what I expected. I should mention at this point that I'm using the downloaded version, not CVS sources.
I was executing a two-statement batch consisting of an insert followed by a select last_insert_rowid(). However, the ExecuteScalar method did not contain a loop to look for results, and thus always returned null. I understand Robert has already fixed this in CVS.
I was also puzzled by the DataReader Read() method, which seems to always return true for the first Read(), but that may be due to code intrinsics I haven't fully understood.
How do I best go about creating a CVS diff on Windows? (personally I'm more into visual tools, so please bear with me).
In case this would work for you, these are the modified methods:
Added try/finally block in Connection.Close:
public void Close ()
if (mState != ConnectionState.Closed)
if (mpTrans != null)
Debug.Assert (mpTrans == null);
for (int i = 0; i < mpCmds.Count; ++i)
mState = ConnectionState.Closed;
if( sqlite != null )
sqlite = null;
Added loop to Command.ExecuteScalar:
public Object ExecuteScalar ()
// ExecuteReader and get value of first column of first row
IDataReader pReader = ExecuteReader();
Object pObj = null;
bool more = true;
while( more )
if (pReader.Read() && pReader.FieldCount > )
pObj = pReader.GetValue( 0 );
more = false;
more = pReader.NextResult();
I recommend using TortoiseCVS for integration with Windows Explorer. Has good Diff tools etc.
My understanding of the ExecuteScalar functionality is the same as Robert Simpson's. I've fixed it in CVS for this as well. No matter how many statements are provided, ExecuteScalar will now only return the first column of the first row of the first row-returning statement, but still execute all statements to the end.
As for the other fix, you could create a bug report and attach a CVS diff to the bug.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.