【发布时间】:2014-06-11 10:57:46
【问题描述】:
我的应用中有 3 个数据库(客户、客户、产品)。我想将一个 DB 转移到另外两个 DB。
三个 DB 被加密,而那些加密的 KEYS 是不同的。 如果我对三个数据库使用相同的密钥,它可以工作。但如果我使用不同的密钥,它会返回错误代码 26。
我使用下面的代码来附加数据库。请指导我。
// _database 现在等于客户端。
NSMutableString *tempString = [[NSMutableString alloc]initWithString:@"attach DATABASE 'customer' as c1 "];
int resultCode = sqlite3_exec(_database, [tempString UTF8String], NULL, NULL, NULL);
[tempString release]; tempString = nil;
if (resultCode == SQLITE_OK)
{
tempString = [[NSMutableString alloc]initWithString:@"INSERT INTO table SELECT * FROM c1.table"];
sqlite3_stmt *stmt_version = 0x00;
resultCode = sqlite3_exec(_database, [tempString UTF8String], NULL, &stmt_version, NULL);
[tempString release]; tempString = nil;
sqlite3_finalize(stmt_version);
if (resultCode == SQLITE_OK)
{
status = YES;
}
}
tempString = [[NSMutableString alloc]initWithString:@"DETACH DATABASE c1 "];
sqlite3_exec(_database, [tempString UTF8String], NULL, NULL, NULL);
[tempString release]; tempString = nil;
【问题讨论】: