Results 1 to 2 of 2

Thread: Db2cli

  1. #1
    Join Date
    Jul 2008
    Posts
    5

    Unanswered: Db2cli

    Hello,
    I need to get list of data sources on my instance.

    Code:
    	/* Handles */   
    	SQLHENV  henv = SQL_NULL_HENV;
    	SQLHDBC  hdbc = SQL_NULL_HDBC;
    	SQLHSTMT hstmt= SQL_NULL_HSTMT;
    
    	/* Local variables */   
    	SQLRETURN     sqlrc;   
    
    	SQLWCHAR  dbAliasBuf[SQL_MAX_DSN_LENGTH + 1]; /* buf. to read the db. dir. */
    	SQLWCHAR  dbCommentBuf[255];
    	SQLSMALLINT aliasLen, commentLen;
    
    	sqlrc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);   
    
    	sqlrc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
    
    	sqlrc = SQLDataSources(henv, SQL_FETCH_NEXT, dbAliasBuf, SQL_MAX_DSN_LENGTH + 1, &aliasLen, dbCommentBuf, 255, &commentLen);
    
    	std::cout << sqlrc << std::endl;
    
    	while ( sqlrc != SQL_NO_DATA_FOUND ) 
    	{
    		std::cout << dbAliasBuf << " " << dbCommentBuf << std::endl;
    		sqlrc = SQLDataSources(henv, SQL_FETCH_NEXT, dbAliasBuf, SQL_MAX_DSN_LENGTH + 1, &aliasLen, dbCommentBuf, 255, &commentLen);
    	}
    This code returns following:
    0
    0026E47C 0026E274

    What does it mean? Why doesnt't dbAliasBuf return name of the instance?

    Thanks
    Adam Kovari

  2. #2
    Join Date
    Jul 2008
    Posts
    5
    I just needed to turn off unicode support in my compiler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •