gpt4 book ai didi

sql - 我有一个sqlite语法错误。什么不对?

转载 作者:行者123 更新时间:2023-12-03 18:27:01 25 4
gpt4 key购买 nike

我有一个sqlite语法错误。什么不对?

我的代码:

+ (void)insertUpdateCatalogTime:(NSString *)time
{
NSLog(@"%@", time);
sqlite3 *database;
if(sqlite3_open([DatabaseManager databasePath], &database) == SQLITE_OK)
{
const char *sqlStatement = [[NSString stringWithFormat:@"UPDATE t_catalog SET updateTime=%@", time] cStringUsingEncoding:NSASCIIStringEncoding];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
while(sqlite3_step(compiledStatement) == SQLITE_ROW);
}
else
{
NSLog(@"sqlite3_prepare_v2 error %s", sqlite3_errmsg(database));
}
sqlite3_finalize(compiledStatement);
}
else
{
NSLog(@"sqlite3_open error");
}
sqlite3_close(database);
}


并记录:

 2012-05-10 14:23:04
sqlite3_prepare_v2 error near "14": syntax error

最佳答案

您是否尝试用单引号将updateTime包装起来?

const char *sqlStatement = [[NSString stringWithFormat:@"UPDATE t_catalog SET updateTime='%@'", time] cStringUsingEncoding:NSASCIIStringEncoding];

关于sql - 我有一个sqlite语法错误。什么不对?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10672844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com