如何使用SQLite写入数据到数据库
答案:2 悬赏:70
解决时间 2021-03-21 20:31
- 提问者网友:我是我
- 2021-03-21 00:57
我使用下面的代码写entry到数据库,但是没有反应,不知道为什么,请高手帮我看看哈,谢谢NSString* user_Name=txt_UserName.text;NSString* password=txt_Password.text;NSString* rePassword=txt_RePassword.text;if ([password isEqualToString:rePassword]) {sqlite3 *database;sqlite3_stmt *compiledQuery;// Open the database from the users filessytemif(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { // Setup the SQL Statement and compile it for faster access const char *sqlStatement = "insert into Main values(?,?)"; sqlite3_prepare_v2(database, sqlStatement, -1, &compiledQuery, NULL); sqlite3_bind_text(compiledQuery, 1, [user_Name UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledQuery, 2, [password UTF8String], -1, SQLITE_TRANSIENT); if(SQLITE_DONE != sqlite3_step(compiledQuery)) NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database)); sqlite3_finalize(compiledQuery); sqlite3_close(database);}
最佳答案
- 二级知识专家网友:茫然不知崩溃
- 2021-03-21 02:14
"insert into Main values(?,?)"这句都没有列名只有值了.
全部回答
- 1楼网友:萝莉姐姐鹿小北
- 2021-03-21 03:46
如何用qt使用sqlite数据库,写入变量
qstring sql = "insert into info values('"; sql += usr; sql += "','"; sql += pwd; sql += "')"; query.exec(sql) 大概是这样,具体你对一下,可能有写错的地方 可一把这个debug出来,完了放到一个数据库软件中 看下能执行不
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯