I have 3 databases(customer,client,product) in my app. I want to transfer one DB to other two DB.
Three DB are encrypted and those encryption KEYS are different. If I have use the same key for three DB, It works. But If i have use different key's , it returns error code 26.
I am using below code for attaching the Databases. Please guide me.
// _database is equal to client now.
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;