*On 16/11/16 17:07, Dimitry Sibiryakov wrote:* > *16.11.2016 20:32, d4t4f...@gmail.com wrote: * >> I'm calling SQLGetConnectAttr() with the SQL_ATTR_CURRENT_CATALOG >> attribute, but it does not seem to return anything meaningful. > Do you check its return value? It must be SQL_NO_DATA if you didn't > call SQLSetConnectAttr() beforehand. I don't call SQLSetConnectAttr() before. Explanation below. Actually, I'm calling SQLGetConnectAttr() twice: One to get the necessary buffer (string) lenght. The second time is to actually retrieve the string. None fails. My code is this:
SQLRETURN retcode; SQLINTEGER charsNeeded = 0; char *dbName; retcode = SQLGetConnectAttr(connHandle, SQL_ATTR_CURRENT_CATALOG, NULL, (SQLINTEGER) 0, (SQLINTEGER *) &charsNeeded); if (SQL_SUCCEEDED(retcode)) { dbName = malloc(charsNeeded++); //Add one to get a buffer with a trailing NULL dbName[charsNeeded++] = 0; //Append NULL retcode = SQLGetConnectAttr(connHandle, SQL_ATTR_CURRENT_CATALOG, dbName, charsNeeded, &charsNeeded); if (SQL_SUCCEEDED(retcode)) { desc->name = GB.NewZeroString(dbName); //This creates a Gambas string with a copy of the ODBC-retrieved string. } else { reportODBCError("SQLGetConnectAttr SQL_ATTR_CURRENT_CATALOG (string)", connHandle, SQL_HANDLE_DBC); } } else { reportODBCError("SQLGetConnectAttr SQL_ATTR_CURRENT_CATALOG (len)", connHandle, SQL_HANDLE_DBC); } The calls do not actually fail (reportODBCError() is never called), and the calls do fetch data, but it is not what I am looking for. Also, I never call SQLSetConnectAttr() with SQL_ATTR_CURRENT_CATALOG, as I am normally connecting with SQLDriverConnect(), directly passing a connection string which includes the database name. It looks like the driver does not populate its database name attribute from the connection string. Just in case, the connstring I'm using is "Driver=Firebird;DataSource=localhost;Port=3050;Database=localhost:/tmp/FBExample;UId=SYSDBA;Pwd=password;". The routine to get the database name is called only when the component connects to the DB successfully.
------------------------------------------------------------------------------
_______________________________________________ Firebird-odbc-devel mailing list Firebird-odbc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-odbc-devel