"yoky" <[EMAIL PROTECTED]> wrote in
message
news:[EMAIL PROTECTED]
>    I try to select like this:
>        sqlite3_prepare(db, "select ?,?,? from tbl1 where ID=1", -1,
> &stat, 0);
>        sqlite3_bind_text(stat, 1, "ID", -1, 0);
>        sqlite3_bind_text(stat, 2, "age", -1, 0);
>        sqlite3_bind_text(stat, 3, "name", -1, 0);

A parameter represents a literal. You can't bind a column name. After 
binding, your query is equivalent to

select 'ID','age','name' from tbl1 where ID=1;

>   The return value of sqlite3_step(stat) was SQLITE_ROW, but the
> values I got were 0,
>   why?

Because the value of the column is a string (the same string literal you 
bound to the parameter), which gets converted to int, and since it 
doesn't look like an integer it gets converted to zero.

> I think maybe sqlite3_bind() can not bind the column name.

Quite.

>    The reson I try to select by "select ?,?,?.. from table where ..."
> but not "select * from table where ..."

But why not

select ID, age, name where ...;

Igor Tandetnik



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

Reply via email to