Unable to fix 2nd parameter to sqlite3_bind() out of range
Posted: 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.
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.