Page 1 of 1

Unable to fix 2nd parameter to sqlite3_bind() out of range

Posted: Wed 26 Jan 2011 18:53
by scope_creep
Created the following method.

private void CompoundedTransactedEntry(IList CompoundedList)
{
SQLiteCommand cmd = new SQLiteCommand();
cmd.Connection = Connection;
Connection.Open();

//Create transaction since we are assigning large block.
Trans = Connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
cmd.Transaction = Trans;

try
{
foreach (Buffer buf in CompoundedList)
{
cmd.CommandText = SQL.ProvisionEntry();

// Create the parameters.
cmd.Parameters.Add("IDMEFXML", buf.IDMEFXML);
cmd.Parameters.Add("COLLECTOR", buf.CollectorName);

int aff = cmd.ExecuteNonQuery();
}
Trans.Commit();
}
catch (SQLiteException e)
{
Trans.Rollback();
//TODO: Report failure and drop to directory create.
}
finally
{
Connection.Close();
}
}

to wrap a number of inserts around a transaction as suggested by Sqlite3 pattern for fast optimal db inserts.

Using the following insert.

"insert into IDMEF(MESSAGENO,MESSAGE,COLLECTORNAME) values(null, :IDMEFXML, :COLLECTOR)";

Using the following table definition IDMEF.

MESSAGENO INTEGER PRIMARY KEY,
CREATEDATE DEFAULT CURRENT_TIMESTAMP,
MESSAGE VARCHAR(40000),
COLLECTORNAME VARCHAR(32)

It works for one row but fails for two or more. Returning an exception

2nd parameter to sqlite3_bind() out of range

I'm unable to identify whats causing the problem, but I think it's something to do with null on the primary key, but can't identify whats causing it.

Any help would be appreciated.
Thanks.

Posted: Thu 27 Jan 2011 08:58
by Shalex
1. As I understood, your SQL.ProvisionEntry() method returns "insert into IDMEF(MESSAGENO,MESSAGE,COLLECTORNAME) values(null, :IDMEFXML, :COLLECTOR)". But you didn show the definition for your Buffer type and the way you are invoking the CompoundedTransactedEntry() method (the value you are passing to it).
Please send us a small complete test project with the corresponding DDL/DML script to reproduce the issue in our environment.

2. The version (x.xx.xxx) and edition of your dotConnect for SQLite. You can find it in the Tools > SQLite > About menu of Visual Studio.

3. If your edition is Professional, try to debug your application with the dbMonitor tool that performs per-component tracing of database events such as commit, rollback, SQL statement execute etc.
Download link: http://www.devart.com/dbmonitor/dbmon3.exe
Documentation: http://www.devart.com/dotconnect/sqlite ... nitor.html
In dbMonitor you will find the SQL statement that fails to execute and the values of parameters. Try executing the same statement (with the same parameters) using another tool. Does the problem persist in this case as well?

Posted: Thu 27 Jan 2011 09:04
by Shalex
4. Please also specify your call stack.

Forwarded project as suggested

Posted: Thu 03 Feb 2011 15:57
by scope_creep
Forwarded the wee test project as suggested with db included. Its a vs2010 project on windows 2008 enterprise sp2, call stack is very slim, only 3 calls deeps and is easy to determine.

Version is 3.0.86.0 which I think is the latest version.

Bob.

Forwarded project as suggested

Posted: Mon 07 Feb 2011 00:20
by scope_creep
Shalex,
Has there been any update on this. I forwarded the test project 4 days ago.

Posted: Mon 07 Feb 2011 17:43
by Shalex
Our support has a two business days response policy. We have answered you by e-mail.

Operation completed.

Posted: Tue 08 Feb 2011 14:47
by scope_creep
Tried the fix that Aleksandr posted in email. It works as expected. A case on my part of RTFM. At least I followed Pearly Soames maxim, of giving a little taking a little.

You can close this.

Thanks to both.
Bob.