Link to home
Start Free TrialLog in
Avatar of blueadmin
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.
ASKER CERTIFIED SOLUTION
Avatar of schwertner
schwertner
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can install required dlls in application directory.  You need to set environment variable TNS_ADMIN to point to where tnsnames.ora file will be kept eg application directory.

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.
/* 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=TESTDSNLESS.WORLD;UID=URusername;PWD=URpassword";

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_str[_MAX_PATH + 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;
}
This is a copy of all the oracle libraries loaded when I ran an OCI program.

'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oci.dll', No symbols loaded.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oraclient9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORACORE9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORANLS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAUNLS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oravsn9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oracommon9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orageneric9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAXML9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAXSD9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orannzsbb9.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\oranl9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranldap9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oraldapclnt9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orancrypt9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oratrace9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranro9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranhost9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranoname9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORANCDS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orantns9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranms.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\oranmsp.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORAPLS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASLAX9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASNLS9.DLL', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\orawtc9.dll', Cannot find or open a required DBG file.
'ocite.exe': Loaded 'F:\Oracle\ora92\bin\ORASQL9.DLL', Cannot find or open a required DBG file.
Avatar of blueadmin
blueadmin

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.
Well,  what fails, an error message might be helpful.
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.