为什么sqlite只插入一列?

时间:2022-05-11 15:26:56

I get only the second value inserted into the database. dataHold.Id has a value, as does aTextField. However, when I look at the database, the Id isn't being inserted. Is the sqlite below correct?

我只获得插入数据库的第二个值。 dataHold.Id有一个值,aTextField也是如此。但是,当我查看数据库时,未插入Id。下面的sqlite是否正确?

const char *sql = "insert into Userdata (Id, Name) Values(?, ?)";
    sqlite3_stmt *selectstmt;
    if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
      sqlite3_bind_int(selectstmt, dataHold.Id, 1);
      sqlite3_bind_text(selectstmt, 2, [aTextField.text UTF8String], -1, SQLITE_TRANSIENT);
      sqlite3_step(selectstmt);

1 个解决方案

#1


7  

Should this

sqlite3_bind_int(selectstmt, dataHold.Id, 1);

be

sqlite3_bind_int(selectstmt, 1, dataHold.Id);

?

#1


7  

Should this

sqlite3_bind_int(selectstmt, dataHold.Id, 1);

be

sqlite3_bind_int(selectstmt, 1, dataHold.Id);

?