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

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
scope_creep
Posts: 12
Joined: Mon 24 Jan 2011 18:21

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

Post by scope_creep » Wed 26 Jan 2011 18:53

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 27 Jan 2011 08:58

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?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 27 Jan 2011 09:04

4. Please also specify your call stack.

scope_creep
Posts: 12
Joined: Mon 24 Jan 2011 18:21

Forwarded project as suggested

Post by scope_creep » Thu 03 Feb 2011 15:57

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.

scope_creep
Posts: 12
Joined: Mon 24 Jan 2011 18:21

Forwarded project as suggested

Post by scope_creep » Mon 07 Feb 2011 00:20

Shalex,
Has there been any update on this. I forwarded the test project 4 days ago.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 07 Feb 2011 17:43

Our support has a two business days response policy. We have answered you by e-mail.

scope_creep
Posts: 12
Joined: Mon 24 Jan 2011 18:21

Operation completed.

Post by scope_creep » Tue 08 Feb 2011 14:47

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.

Post Reply