![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I am trying to connect to a network database server in my embedded SQL code using a DSN. Just before I do the CONNECT statement, I try to find the network database server using db_find_engine(&sqlca, theBnk), where "theBnk" is network database server name. For some reasons, this function is failing with SQLCODE -100. And this function is successful if database server is runing on local machine. Also, I can connect to this network database server using ODBC Administrator with the same DSN. Could anybody help me why db_find_engine() function is failing for a network database server ? Below is my code that illustrates this: |
#3
| |||
| |||
|
|
Hi, I am trying to connect to a network database server in my embedded SQL code using a DSN. Just before I do the CONNECT statement, I try to find the network database server using db_find_engine(&sqlca, theBnk), where "theBnk" is network database server name. For some reasons, this function is failing with SQLCODE -100. And this function is successful if database server is runing on local machine. Also, I can connect to this network database server using ODBC Administrator with the same DSN. Could anybody help me why db_find_engine() function is failing for a network database server ? Below is my code that illustrates this: if ( db_init(&sqlca) != 0 ) { // Locate the engine. if ( db_find_engine(&sqlca, theBnk) ) { // Engine located, connect to it. EXEC SQL CONNECT USING 'DSN=test'; if ( SQLCODE == SQLE_NOERROR ) { HaveDBConnection = TRUE; } else { printf("Unable to establish connection to database. SQLCODE = [%d]\n", SQLCODE); } } else { printf("Unable to find database engine. SQLCODE = [%d]\n", SQLCODE); } } else { printf("Unable to initialize database. SQLCODE = [%d]\n", SQLCODE); } Thanks, V Jain |
#4
| |||
| |||
|
|
Hi, I am trying to connect to a network database server in my embedded SQL code using a DSN. Just before I do the CONNECT statement, I try to find the network database server using db_find_engine(&sqlca, theBnk), where "theBnk" is network database server name. For some reasons, this function is failing with SQLCODE -100. And this function is successful if database server is runing on local machine. Also, I can connect to this network database server using ODBC Administrator with the same DSN. Could anybody help me why db_find_engine() function is failing for a network database server ? Below is my code that illustrates this: if ( db_init(&sqlca) != 0 ) { // Locate the engine. if ( db_find_engine(&sqlca, theBnk) ) { // Engine located, connect to it. EXEC SQL CONNECT USING 'DSN=test'; if ( SQLCODE == SQLE_NOERROR ) { HaveDBConnection = TRUE; } else { printf("Unable to establish connection to database. SQLCODE = [%d]\n", SQLCODE); } } else { printf("Unable to find database engine. SQLCODE = [%d]\n", SQLCODE); } } else { printf("Unable to initialize database. SQLCODE = [%d]\n", SQLCODE); } Thanks, V Jain |
#5
| |||
| |||
|
|
db_find_engine is designed to find a local server with the given name using shared memory. You could use db_string_ping_server if you want to use a connection string to determine if you can connect to a server (without doing the connection to the database). I recommend not calling db_find_engine unless it is only for a local server. In your case, you can skip the db_find_engine or db_string_ping_server, and just attempt the database connection first. If the connection fails, the error will indicate if the server was found or not. -- Ian McHardy (iAnywhere Solutions) Please reply only to the newsgroup. Whitepapers, TechDocs, bug fixes are all available through the iAnywhere Developer Community at http://www.ianywhere.com/developer V Jain> wrote in message news:471663d9.75cc.1681692777 (AT) sybase (DOT) com... Hi, I am trying to connect to a network database server in my embedded SQL code using a DSN. Just before I do the CONNECT statement, I try to find the network database server using db_find_engine(&sqlca, theBnk), where "theBnk" is network database server name. For some reasons, this function is failing with SQLCODE -100. And this function is successful if database server is runing on local machine. Also, I can connect to this network database server using ODBC Administrator with the same DSN. Could anybody help me why db_find_engine() function is failing for a network database server ? Below is my code that illustrates this: if ( db_init(&sqlca) != 0 ) { // Locate the engine. if ( db_find_engine(&sqlca, theBnk) ) { // Engine located, connect to it. EXEC SQL CONNECT USING 'DSN=test'; if ( SQLCODE == SQLE_NOERROR ) { HaveDBConnection = TRUE; } else { printf("Unable to establish connection to database. SQLCODE = [%d]\n", SQLCODE); } } else { printf("Unable to find database engine. SQLCODE = [%d]\n", SQLCODE); } } else { printf("Unable to initialize database. SQLCODE = [%d]\n", SQLCODE); } Thanks, V Jain |
![]() |
| Thread Tools | |
| Display Modes | |
| |