Trouble inserting data

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
brettg
Posts: 1
Joined: Tue 09 Dec 2008 11:33

Trouble inserting data

Post by brettg » Tue 09 Dec 2008 11:37

Hello. I'm using your Sqlite Data Provider with C#, and I'm having a bit of trouble inserting BLOB data using Command Parameters. I don't know if it has to do with the BLOB data or not, as I don't use Command Parameters anywhere else.

I have a table created like this:

CREATE TABLE [My_Values] (ID INTEGER PRIMARY KEY NOT NULL, ParentID INT NOT NULL, Name TEXT NOT NULL, Type INT NOT NULL, Data BLOB, Encrypted INT NOT NULL DEFAULT 0

I want to insert a row, so I use this SQL:

INSERT INTO [My_Values] (Name, ParentID, Type, Encrypted, Data) VALUES(@Name, @ParentID, @Type, @Encrypted, @Data)

Then I create the parameters:

cmd.Parameters.Add("@Name", SQLiteType.Text, sValueName.Length).Value = sValueName;
cmd.Parameters.Add( "@ParentID", SQLiteType.Int32, 4 ).Value = (int) nParent;
cmd.Parameters.Add( "@Type", SQLiteType.Int32, 4 ).Value = (int) nType;
cmd.Parameters.Add( "@Encrypted", SQLiteType.Int32, 4 ).Value = 0;
cmd.Parameters.Add( "@Data", SQLiteType.Blob, pData.Length ).Value = vData;

vData is just a byte[] with a length of 4. When I execute the Command, I get the error below. Any idea what I'm doing wrong?

"2nd parameter to sqlite3_bind() out of range
bind or column index out of range"

Thx
-BrettG

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

Post by Shalex » Thu 11 Dec 2008 14:06

We have answered you by e-mail.

Post Reply