Hi, I am using the MySQL server and it's myodbc_mysql client programme. When i connect to the local machine, it works perfectly. But i don't know how do i connect to remote machine when using it in pure ODBC fashion. ------------------------------------------ Available way is like follwing, 1. mysql -u root -h abc.xyz.com -p ( for interactive command line tool ) or 2. real_connect( user, host, db, ..) ( for CAPI ) these works perfectly. --------------------------------------------- I actually want something like following, and want to give remote host name in this programme. Following programme by default contacts to localhost:3306 and does the query. Depending upon some conditions i will be switching the localhost name and remote host name. I found couple of solutions in PHP, CAPI etc, but that doesn't suite my need. ---------------------------------------------- #include <stdio.h> #include <string.h> #include "isql.h" #include "odbc_funcs.h" #include "odbc_types.h" #define MIB_DB_DSN "blob_test" #define MIB_DB_USER "root" #define MIB_DB_PASSWORD "venkat" #define TRUE 1 #define FALSE 0 SQLHDBC hdbc; SQLHENV henv; void displayError( SQLHENV hEnv, SQLHDBC hDbc, SQLHSTMT hStmt, int iRC, int iLineNum ) { SQLCHAR szBuffer[ SQL_MAX_MESSAGE_LENGTH ]; /* msg. buffer */ SQLCHAR szSqlState[ SQL_SQLSTATE_SIZE ]; /* statement buf. */ SQLINTEGER iSqlCode; /* return code */ SQLSMALLINT iLength; /* return length */ fprintf( stderr, "-----------------------\n" ); fprintf( stderr, "SQL error : %d\n", iRC ); fprintf( stderr, "line number : %d\n", iLineNum ); while( SQL_SUCCESS == SQLError( hEnv, hDbc, hStmt, szSqlState, &iSqlCode, szBuffer, SQL_MAX_MESSAGE_LENGTH - 1, &iLength ) ) { fprintf( stderr, "SQL state : %s\n", szSqlState ); fprintf( stderr, "native error code : %ld\n", iSqlCode ); fprintf( stderr, "%s\n", szBuffer ); } /* while */ fprintf( stderr, "-----------------------\n" ); } /* displayError */ int main( int argc, char* argv[] ) { SQLRETURN nResult; SQLHSTMT hstmt; if(SQLAllocEnv(&henv) != SQL_SUCCESS) { displayError( henv, hdbc, NULL, 0, __LINE__ ); printf( "\nUnable to get the database handle"); return FALSE; } if(SQLAllocConnect( henv, (SQLHDBC FAR *)&hdbc) != SQL_SUCCESS) { displayError( henv, hdbc, NULL, 0, __LINE__ ); printf( "\nUnable to get the database handle" ); return FALSE; } if((nResult = SQLConnect( hdbc, (unsigned char *)MIB_DB_DSN, SQL_NTS, (unsigned char *)MIB_DB_USER, SQL_NTS, (unsigned char *)MIB_DB_PASSWORD, SQL_NTS)) != SQL_SUCCESS) { displayError( henv, hdbc, NULL, 0, __LINE__ ); printf( "\nUnable to connect to the database" ); return FALSE; } SQLDisconnect(hdbc); SQLFreeConnect(hdbc); SQLFreeEnv(henv); exit(0); } /* end, main() */ ----------------------------------------------- Thaning you for speedier reponse, with regards, -peri
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php