Why I can't attach an encrypted database to an encrypted database

There are 2 encrypted sqlite3 database: test.db and abc.db. The password of both database are “123456”. Now I want to attach abc.db to test.db. But the return value is 26. Why?

sqlite3_open(“D:\test.db", &db);
sqlite3_key(db, ”123456“, 6);
sqlite3_exec(db, (const char*)“PRAGMA cipher_use_hmac = off”, NULL, NULL, NULL);
sqlite3_exec(db, (const char*)“PRAGMA cipher_page_size = 1024”, NULL, NULL, NULL);
sqlite3_exec(db, (const char*)“PRAGMA kdf_iter = 4000”, NULL, NULL, NULL);
char chAttach[500];
sprintf_s(chAttach,500,“ATTACH DATABASE ‘D:\abc.db’ AS ‘db2’ KEY ‘%s’”,“123456”);
int nRet=sqlite3_exec(db, (const char*)chAttach, NULL, NULL, NULL);
if ( nRet!= SQLITE_OK) //nRet is 26
{
MessageBox(NULL,“Failure”,“”,MB_OK);
}

If I attach a unencrypted database to a unencrypted database. It will work. Why I can’t attach an encrypted database to an encrypted database?

@jackie - is the abc.db using non-standard settings like test.db? If so, you’d need to account for those when attaching the database.