blueadmin
asked on
Deploy Application with Oracle Client 9.2
Hello
I have written an application with VC++ 6.0, I use OCI interface of Oracle Client to connect to Oracle server. Now i want to deploy my application to others clients. These Clients must install Oracle Client, or can we create a pakage that contain needed "dll" of Oracle Client (if we can do that, how can we replace some definitions in TNSName of Oracle Client)
thanks advance.
I have written an application with VC++ 6.0, I use OCI interface of Oracle Client to connect to Oracle server. Now i want to deploy my application to others clients. These Clients must install Oracle Client, or can we create a pakage that contain needed "dll" of Oracle Client (if we can do that, how can we replace some definitions in TNSName of Oracle Client)
thanks advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
/* here is an example using ODBC */
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <stdlib.h>
#include <stdio.h>
#define MAXCOLS 5
#define COL1_LEN 80
int main ( int argc, char *argv[] )
{
HENV m_henv;
HDBC m_hdbc;
HSTMT m_hstmt;
SQLCHAR query[] = "SELECT COL1 FROM TEST";
SQLCHAR szConnStrOut[255];
SQLCHAR col1val[COL1_LEN];
SQLCHAR m_connect[] = "DRIVER={Microsoft ODBC for Oracle};CONNECTSTRING=TEST DSNLESS.WO RLD;UID=UR username;P WD=URpassw ord";
SQLINTEGER col1_len;
SQLSMALLINT pcbConnStrOut;
RETCODE ret;
char tns_string[] = "TESTDSNLESS.WORLD =\n\
(DESCRIPTION =\n\
(ADDRESS_LIST =\n\
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))\n\
)\n\
(CONNECT_DATA =\n\
(SERVICE_NAME = orcl.world)\n\
)\n\
)\n";
char buf[_MAX_PATH],tns_admin_s tr[_MAX_PA TH + 11];
FILE *tnsnames = fopen( "tnsnames.ora", "w" );
fputs( tns_string, tnsnames );
fclose( tnsnames );
sprintf( tns_admin_str, "TNS_ADMIN=\"%s\"", _getcwd( buf, _MAX_PATH - 1 ) );
_putenv( tns_admin_str );
SQLAllocEnv( &m_henv );
ret = SQLAllocConnect( m_henv, &m_hdbc );
ret = SQLDriverConnect( m_hdbc, (SQLHWND) NULL, m_connect, SQL_NTS, szConnStrOut, 255, &pcbConnStrOut, SQL_DRIVER_COMPLETE );
if ( ret == SQL_SUCCESS ) {
SQLAllocStmt( m_hdbc, &m_hstmt );
ret = SQLExecDirect( m_hstmt, query, SQL_NTS );
if ( ( ret == SQL_SUCCESS ) || ( ret == SQL_SUCCESS_WITH_INFO ) ) {
printf( "ODBC Connect Success with %s\n", szConnStrOut );
SQLBindCol( m_hstmt, 1, SQL_C_CHAR, col1val, COL1_LEN, &col1_len );
while ( TRUE ) {
ret = SQLFetch( m_hstmt );
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO){
printf("%s\n", col1val );
} else {
break;
}
}
}
}
SQLDisconnect( m_hdbc );
return 0;
}
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <stdlib.h>
#include <stdio.h>
#define MAXCOLS 5
#define COL1_LEN 80
int main ( int argc, char *argv[] )
{
HENV m_henv;
HDBC m_hdbc;
HSTMT m_hstmt;
SQLCHAR query[] = "SELECT COL1 FROM TEST";
SQLCHAR szConnStrOut[255];
SQLCHAR col1val[COL1_LEN];
SQLCHAR m_connect[] = "DRIVER={Microsoft ODBC for Oracle};CONNECTSTRING=TEST
SQLINTEGER col1_len;
SQLSMALLINT pcbConnStrOut;
RETCODE ret;
char tns_string[] = "TESTDSNLESS.WORLD =\n\
(DESCRIPTION =\n\
(ADDRESS_LIST =\n\
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))\n\
)\n\
(CONNECT_DATA =\n\
(SERVICE_NAME = orcl.world)\n\
)\n\
)\n";
char buf[_MAX_PATH],tns_admin_s
FILE *tnsnames = fopen( "tnsnames.ora", "w" );
fputs( tns_string, tnsnames );
fclose( tnsnames );
sprintf( tns_admin_str, "TNS_ADMIN=\"%s\"", _getcwd( buf, _MAX_PATH - 1 ) );
_putenv( tns_admin_str );
SQLAllocEnv( &m_henv );
ret = SQLAllocConnect( m_henv, &m_hdbc );
ret = SQLDriverConnect( m_hdbc, (SQLHWND) NULL, m_connect, SQL_NTS, szConnStrOut, 255, &pcbConnStrOut, SQL_DRIVER_COMPLETE );
if ( ret == SQL_SUCCESS ) {
SQLAllocStmt( m_hdbc, &m_hstmt );
ret = SQLExecDirect( m_hstmt, query, SQL_NTS );
if ( ( ret == SQL_SUCCESS ) || ( ret == SQL_SUCCESS_WITH_INFO ) ) {
printf( "ODBC Connect Success with %s\n", szConnStrOut );
SQLBindCol( m_hstmt, 1, SQL_C_CHAR, col1val, COL1_LEN, &col1_len );
while ( TRUE ) {
ret = SQLFetch( m_hstmt );
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO){
printf("%s\n", col1val );
} else {
break;
}
}
}
}
SQLDisconnect( m_hdbc );
return 0;
}
This is a copy of all the oracle libraries loaded when I ran an OCI program.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oci.d ll', No symbols loaded.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oracl ient9.dll' , Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORACO RE9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORANL S9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAUN LS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oravs n9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oraco mmon9.dll' , Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orage neric9.dll ', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAXM L9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAXS D9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orann zsbb9.dll' , Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oran9 .dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranl 9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranl dap9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orald apclnt9.dl l', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranc rypt9.dll' , Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oratr ace9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranr o9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranh ost9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orano name9.dll' , Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORANC DS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orant ns9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranm s.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranm sp.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAPL S9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASL AX9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASN LS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orawt c9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASQ L9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oci.d
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oracl
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORACO
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORANL
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAUN
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oravs
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oraco
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orage
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAXM
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAXS
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orann
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oran9
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranl
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranl
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orald
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranc
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oratr
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranr
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranh
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orano
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORANC
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orant
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranm
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranm
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAPL
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASL
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASN
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orawt
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASQ
ASKER
Ok
I have copy your code(modify paramenter in tnsnames.ora) and build test.exe.
I have build a pakage (setup .msi inlcudes test.exe and all dlls that you had showed me).
I install to another client, it's unsucess.
please help me
thanks in advance.
I have copy your code(modify paramenter in tnsnames.ora) and build test.exe.
I have build a pakage (setup .msi inlcudes test.exe and all dlls that you had showed me).
I install to another client, it's unsucess.
please help me
thanks in advance.
Well, what fails, an error message might be helpful.
ASKER
Sorry for my late.
ok, it appear
"Oracle client and networking component was not found. These components are
suppled by Oracle and are part of the Oracle Version 7.3.3 or later client software
installation.
Provider is unable to function until these components are installed"
thanks in advance.
ok, it appear
"Oracle client and networking component was not found. These components are
suppled by Oracle and are part of the Oracle Version 7.3.3 or later client software
installation.
Provider is unable to function until these components are installed"
thanks in advance.
tnsnames.ora is just a text file. Create one using sql*net configuration tool and use it as a template. You might also need sqlnet.ora to handle all those exotic SQL*Net options.