Installation required to connect to Oracle 11g

Installation required to connect to Oracle 11g

Postby Carles » Wed Mar 20, 2013 8:35 am

Hi,

Can anyone tell me the minimum installation on the client machine to connect to Oracle 11g via ADO? There are some mini-pack, mini-installation, mini dll registration, ... to avoid having to install the entire kit.

Thanks !
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Installation required to connect to Oracle 11g

Postby Rimantas » Wed Mar 20, 2013 10:37 am

Carles wrote:Hi,

Can anyone tell me the minimum installation on the client machine to connect to Oracle 11g via ADO? There are some mini-pack, mini-installation, mini dll registration, ... to avoid having to install the entire kit.

Thanks !


Not sure , but if in the system exist MS Oracle DB provider , then you can to connect to Oracle . I was working with Oracle 10 . Used "MSDAORA" as Oracle provider . Then , as usual :

cOra_prv := alltrim( cOra_prv ) // MSDAORA
cOra_srv := alltrim( cOra_srv )
cOra_usr := alltrim( cOra_usr )
cOra_psw := alltrim( cOra_psw )
TRY
oCnct := TAdoConnect():New( cOra_prv, cOra_srv,, cOra_usr, cOra_psw ):Connect()
CATCH
MsgAlert( "Can't to connect !" )
END
...

This MSDAORA let to work without instalation of Oracle client kit .

Regards !
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Installation required to connect to Oracle 11g

Postby Carles » Wed Mar 20, 2013 12:12 pm

Rimantas


Thanks for your help. This is my purpose, to work without instalation of Oracle client kit . Can you send me your TADOConnect for test ? I'm understand that 1 parameter is "MSDAORA" and 2 parameter the service name. Its true ?
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Installation required to connect to Oracle 11g

Postby Rick Lipkin » Wed Mar 20, 2013 1:00 pm

Carles

When I was working with Oracle I used the client kit for the version of the database I was connecting to. I did a quick search and found this client which should be the latest version.

http://www.oracle.com/technetwork/datab ... 01290.html

The provider was "OraOledb.oracle" .. here is a coding example with ADO. You need to make sure your TnsNames.ora and SqlNet.ora are configured correctly to connect to your database.

Rick Lipkin

Code: Select all  Expand view


xPROVIDER := "OraOledb.oracle"
xSOURCE   := "yourdatabase"
xUSERID   := "youruserid"
xPASSWORD := "yourpassword"


cSql := "Select * from [YourTable]"

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType     := 1        // opendkeyset
oRs:CursorLocation := 3        // local cache
oRs:LockType       := 3        // lockoportunistic

TRY
   oRs:Open(cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oErr
   MsgInfo( "Error in Opening Oracle table" )
   oDlg:End()
   RETURN(.F.)
END TRY

xBrowse( oRs )

oRs:CLose()


 
User avatar
Rick Lipkin
 
Posts: 2633
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Installation required to connect to Oracle 11g

Postby Carles » Wed Mar 20, 2013 2:05 pm

Rick

Thank you. I'll try this example but it will be the second option. I would like the customer didn't have to install any client oracle kit. I'll try to do it with the proposed of Rimantas. If I fail, I will seek the oracle client kit to test your example

Tanks for your suport
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Installation required to connect to Oracle 11g

Postby Rimantas » Wed Mar 20, 2013 2:29 pm

Carles wrote:Rimantas


Thanks for your help. This is my purpose, to work without instalation of Oracle client kit . Can you send me your TADOConnect for test ? I'm understand that 1 parameter is "MSDAORA" and 2 parameter the service name. Its true ?


Carles,
It's old prg from Rao. I'm adding here :

Code: Select all  Expand view

*
*   Program name: AdoConct.Prg
*   Purpose: Create a connection with various databases through ADO (TADOConnect class)
*   Author: Nagesh G. Rao
*   Co-authors: Kleyber Derick and Antonio Ortega
*/

#ifndef __XHARBOUR__
#err "Library for xHarbour only. Does not work for Clipper/Harbour"
#endif

#include "fivewin.ch"
#include "adodef.ch"

///////////////////////
CLASS TAdoConnect

EXPORT:
DATA   oConnect   READONLY
DATA   oDataShape READONLY

EXPORT:
DATA   cProvider    AS CHARACTER
DATA   cDatabase    AS CHARACTER
DATA   cDataSource  AS CHARACTER
DATA   cUserID      AS CHARACTER
DATA   cPassWord    AS CHARACTER

DATA   cError INIT "S_OK"

EXPORT:
METHOD   New()
METHOD   Connect()
METHOD   ConnectDS()
METHOD   IsOpen()  INLINE ( ::oConnect:State > 0 )
METHOD   RecordSet()
METHOD   OpenTable()
METHOD   GetTables()
METHOD   Close()

ENDCLASS

METHOD New( cProvider, cDataSource, cDatabase, cUserID, cPassWord ) CLASS TAdoConnect
if valtype( cProvider   ) == "C" ; ::cProvider    := cProvider ;   endif
if valtype( cDatabase   ) == "C" ; ::cDatabase    := cDatabase ;   endif
if valtype( cDataSource ) == "C" ; ::cDataSource  := cDataSource ; endif
if valtype( cUserID     ) == "C" ; ::cUserID      := cUserID ;     endif
if valtype( cPassWord   ) == "C" ; ::cPassWord    := cPassWord ;   endif
return( Self )
///////////////////////
METHOD Connect() CLASS TAdoConnect
local cStr := "Provider="    + alltrim( ::cProvider )   + ";" + ;
              "Data Source=" + alltrim( ::cDataSource ) + ";" + ;
              "Database="    + alltrim( ::cDataSource ) + ";" + ;
              "User id="     + alltrim( ::cUserID )     + ";" + ;
              "Password="    + alltrim( ::cPassWord )

::oConnect := TOleAuto():New( "ADODB.Connection" )
::cError   := Ole2TxtError()
if ::cError == "S_OK"
   MsgRun( "Jungimasis prie serverio ...", alltrim( ::cDataSource ), { || ::oConnect:Open( cStr ) } )
endif
return( Self )

METHOD ConnectDS() CLASS TAdoConnect
if ::oConnect != NIL .and. ::oDataShape == NIL
   ::oDataShape  := TOleAuto():New( "ADODB.Connection" )
   ::cError      := Ole2TxtError()
   ::oDataShape:ConnectionString := "Provider=MSDataShape;Data " + ::oConnect:ConnectionString
   if ::cError == "S_OK"
      MsgRun( "Jungimasis prie serverio ...", alltrim( ::cDataSource ), ;
      { || ::oDataShape:Open() } )
   endif
endif
return( Self )

METHOD RecordSet( cSql, cWhere, nCursorType, nLockType, nMaxRows ) CLASS TAdoConnect
local oRecSet
local oConnect := ::oConnect
local bOldError
DEFAULT  nCursorType := adOpenDynamic,   ;
         nLockType   := adLockOptimistic
if upper( cSql ) == "SHAPE" // DataShaping is used
   if ::oDataShape == NIL
      ::ConnectDS()
   endif
   oConnect:= ::oDataShape
   cWhere   := NIL
  else  // Normal Sql
   if cWhere != NIL .and. .NOT. " WHERE " $ cSql
      cSql   += (  " WHERE  "+ cWhere )
      cWhere := NIL
   endif
   if " WHERE " $ cSql .and. !( cSql = "SELECT " )
      cSql   := "SELECT * FROM " + cSql
   endif
endif
oRecSet  := TOleAuto():New( "ADODB.RecordSet" )
if ( ::cError := Ole2TxtError() ) == "S_OK"
   WITH OBJECT oRecSet
      :CursorLocation   := adUseClient
      :LockType         := nLockType
      :CursorType       := nCursorType
      :ActiveConnection := oConnect
      :Source           := cSql
      if nMaxRows != NIL
         :MaxRecords    := nMaxRows
      endif
      :CacheSize        := 40
   END
endif
return( oRecSet )

METHOD OpenTable( cSql, cWhere, nCursorType, nLockType, nOptions, nMaxRows, lSilent ) CLASS TAdoConnect
local oRecSet
local oTable
// not using nOptions right now
DEFAULT lSilent := .t. // ( valtype( nMaxRows ) == "N" .and. nMaxRows == 1 )

oRecSet  := ::RecordSet( cSql, cWhere, nCursorType, nMaxRows )
if lSilent
   oRecSet:Open()
  else
   MsgRun( "Lenteles atidarymas ...", "Prasome palaukti ...", { || oRecSet:Open() } )
endif
oTable  := AdoTable():New( oRecSet )
return( oTable )

METHOD GetTables() CLASS TAdoConnect
// This SQL works only for Oracle
// Either use specific SQL for each or use slower ADOX
return( ::OpenTable( "SELECT TABLE_NAME,OWNER,NUM_ROWS FROM ALL_TABLES" ) )

METHOD Close() CLASS TAdoConnect
#ifdef __XHARBOUR__
   ::oConnect:Close()
#else
   ::oConnect:End()
#endif
return( Self )

 


Adodef.ch :

Code: Select all  Expand view

//
// defines for the ADO Stuff
//

// LockType
#define adLockUnspecified   -1
#define adLockReadOnly       1
#define adLockPessimistic    2
#define adLockOptimistic     3
#define adLockBatchOptimistic 4

// CursorType
#define adOpenUnspecified     1
#define adOpenForwardOnly     0
#define adOpenKeyset          1
#define adOpenDynamic         2
#define adOpenStatic          3

// Cursor Location
#define adUseClient           3
#define adUseServer           2

// Options
#define adCmdUnspecified     -1
#define adCmdUnknown          8
#define adCmdText             1
#define adCmdTable            2
#define adCmdStoredProc       4
#define adCmdFile           256
#define adCmdTableDirect    512

#define adHoldRecords       0x100
#define adMovePrevious      0x200
#define adAddNew            0x1000400
#define adDelete            0x1000800
#define adUpdate            0x1008000
#define adBookmark          0x2000
#define adApproxPosition    0x4000
#define adUpdateBatch       0x10000
#define adResync            0x20000
#define adNotify            0x40000
#define adFind              0x80000
#define adSeek              0x400000
#define adIndex             0x800000

// DataType
#define adEmpty              0
#define adTinyInt           16
#define adSmallInt           2
#define adInteger            3
#define adBigInt            20
#define adUnsignedTinyInt   17
#define adUnsignedSmallInt  18
#define adUnsignedInt       19
#define adUnsignedBigInt    21
#define adSingle             4
#define adDouble             5
#define adCurrency           6
#define adDecimal           14
#define adNumeric          131
#define adBoolean           11
#define adError             10
#define adUserDefined      132
#define adVariant           12
#define adIDispatch          9
#define adIUnknown          13
#define adGUID              72
#define adDate               7
#define adDBDate           133
#define adDBTime           134
#define adDBTimeStamp      135
#define adBSTR               8
#define adChar             129
#define adVarChar          200
#define adLongVarChar      201
#define adWChar            130
#define adVarWChar         202
#define adLongVarWChar     203
#define adBinary           128
#define adVarBinary        204
#define adLongVarBinary    205
#define adChapter          136
#define adFileTime          64
#define adDBFileTime       137
#define adPropVariant      138
#define adVarNumeric       139

// BookMark
#define adBookmarkCurrent    0
#define adBookmarkFirst      1
#define adBookmarkLast       2

// Field attributes
#define adFldMayBeNull     0x40


// Options
#define adOptionUnspecified -1
#define adAsyncExecute      16
#define adAsyncFetch        32
#define adAsyncFetchNonBlocking 64
#define adExecuteNoRecords  128
#define adExecuteStream     256
#define adExecuteRecord     512

// Resync
// objRecordset:Resync( affectrecords,resyncvalues )

// affect records
#define adAffectCurrent     1
#define adAffectGroup       2
#define adAffectAll         3   // default (only inside filter)
#define adAffectAllChapters 4

// ResyncValues
#define adResyncAllValues       2   // default
#define adResyncUnderlyingValues    1


// rs=objconn.OpenSchema(querytype,criteria,schemaid)
// ignore schemaid . provider specific

#define adSchemaTables      20
#define adSchemaColumns     4

// State constants

#define adStateClosed       0   //The object is closed
#define adStateOpen     1   //The object is open
#define adStateConnecting   2   //The object is connecting
#define adStateExecuting    4   //The object is executing a command
#define adStateFetching     8   //The rows of the object are being retrieved
 


I believe , that it is a new version of this , which can work and with harbour . But at first you must to check - exist any MS datasource for Oracle in local PC ? I was working with Oracle some years ago and alreday PC another , not the same . Now I checked and at this moment exist "Microsoft ODBC for Oracle" in mine PC. Tomorow I can try it will work with Oracle directly or not ...
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Installation required to connect to Oracle 11g

Postby Rimantas » Thu Mar 21, 2013 7:46 am

Carles ,
Found that - simply check if exist in your system msdaora.dll . In mine case - C:\Program Files\Common Files\System\Ole DB\msdaora.dll . This means that you have MS Oracle DB provider . And that must work , I hope ... :-) . For me that is working .

Regards !
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Installation required to connect to Oracle 11g

Postby Carles » Thu Mar 21, 2013 8:54 am

Rimantas,

Thanks, i'll try it.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1101
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: INFORMAISVRB and 37 guests