C S <[EMAIL PROTECTED]> wrote:
> so here is what i am doing in the code. imageArray
> holds the unsigned shorts(there are 10 of them)
>
> char* blob = reinterpret_cast<char*>(imageArray);
>
> string myString = "insert into Images(ImageID,
> imageData) values(?, 'blob')";

This statement inserts some value (to be bound later) into ImageID 
column, and a string literal 'blob' into imageData column. Is that 
really what you want? From your problem description, I expected 
something like

insert into Images(imageData) values(?);

> int status = sqlite3_prepare_v2(db, myString.c_str(),
> -1, &statement, NULL);
>
> status = sqlite3_bind_blob(statement, 1, imageArray,
> 10 * sizeof(unsigned short), SQLITE_TRANSIENT);

You are binding the blob to a parameter that the statement will try to 
place into ImageID column. You cannot insert a BLOB into a field 
declared INTEGER PRIMARY KEY.

> //execute statement for each row??

How do you mean? You are running an INSERT statement, not a SELECT 
statement. For each row of what?

> while( (status = sqlite3_step(statement)) ==
> SQLITE_ROW);

Luckily, sqlite3_step will never return SQLITE_ROW when executing INSERT 
(or UPDATE or DELETE) statement.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to