On 10/08/2015 03:51 AM, Bart Smissaert wrote:
> As I understand it this should produce a filepointer to the filepath of the
> attached database, given the database handle of file the other database was
> attached to and the database name of the attached database. I checked all
> the return values and also did a select involving tables in both
> databases and all goes fine, so I can be sure that the other database is
> attached OK.
> All I get from sqlite3_db_filename is zero, so no valid file pointer. No
> error messages though.
>
> I am accessing sqlite3.dll (Windows 7) via a std_call dll as I am working
> in VBA here.
>
> Any suggestions what could be the problem?
>
> I am running 3.8.11.1
>
The program below works here.
I'm seeing full paths for databases "main" and "aux", and a zero-length
nul-terminated string for "next" (the in-memory database).
Dan
-----------------------------------------------------
#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv){
int rc;
sqlite3 *db;
rc = sqlite3_open("test.db", &db);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3_open: %s\n", sqlite3_errmsg(db));
exit(1);
}
rc = sqlite3_exec(db, "ATTACH 'other.db' AS 'aux'", 0, 0, 0);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3_exec: %s\n", sqlite3_errmsg(db));
exit(1);
}
rc = sqlite3_exec(db, "ATTACH ':memory:' AS 'next'", 0, 0, 0);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite3_exec: %s\n", sqlite3_errmsg(db));
exit(1);
}
printf("main db is: %s\n", sqlite3_db_filename(db, "main"));
printf("aux db is: %s\n", sqlite3_db_filename(db, "aux"));
printf("next db is: %s\n", sqlite3_db_filename(db, "next"));
return 0;
}