FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ODBC Problem ?
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM

ODBC Problem ?

Posted: Thu Dec 29, 2011 04:12 PM

Hi,
This code in 16 bit version work ok !

oOdbc := TOdbc():New( cDsn, cUserName, cPassword )
IF !oOdbc:lSuccess
MsgInfo("UN succesful login !")
oOdbc:End()
RETURN .f.
ELSE
MsgInfo("succesful login !")
RETURN .t.
ENDIF

In 32 bit version program is prompting another window with putted data from the odbc (database name, host name)
and user name and password even if cDsn, cUserName, cPassword are corrected and user must click "Ok"
This is big problem becouse user unwanted can change database name or host name.
I want loning to go direct if cDsn, cUserName, cPassword are correct or to return .f. like in code.

Any solutions ?

Best regards,

p.s

How can i put picture in here ?

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: ODBC Problem ?

Posted: Thu Dec 29, 2011 06:35 PM

avista

What database are you trying to connect to ?? MS Access ? .. I would recommend ADO over ODBC ..

http://wiki.fivetechsoft.com/doku.php?i ... ted_stuffs

Rick Lipkin

Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM

Re: ODBC Problem ?

Posted: Fri Dec 30, 2011 08:09 AM

Hi Rick,
Thanks for reply

Loging to INFORMIX

Regards,

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: ODBC Problem ?

Posted: Fri Dec 30, 2011 01:53 PM
avista

Several things you will need ..

1) OLEDB ( ado ) client provider for IBM Informix ..
http://www-01.ibm.com/software/data/inf ... ools/csdk/

SDK Downloads here:
http://www14.software.ibm.com/webapp/do ... p?rs=ifxdl

2) You will need to understand the OLEDB connection string syntax for Informix ..
http://connectionstrings.com/informix

Standard
Provider=Ifxoledbc;Data Source=dbName@serverName;User ID=myUsername;Password=myPassword;

Persisting security info in the connection string
Provider=Ifxoledbc;Data Source=dbName@serverName;User ID=myUsername;Password=myPassword;Persist Security Info=true;

The hardest part will be finding the OLEDB Client from IBM from the above link for your platform.. Once you get the OLEDB Informix client .. You can use the Informix connection string like this :

Rick Lipkin

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

cSQL := "SELECT * FROM MYTABLE"

TRY
  oRS:Open(cSQL,'Provider=Ifxoledbc;Data Source=dbName@serverName;User ID=myUsername;Password=myPassword' )
CATCH oErr
   MsgInfo( "Error in Opening MYTABLE table" )
    RETURN(.F.)
END TRY
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM

Re: ODBC Problem ?

Posted: Thu Jan 05, 2012 11:06 AM
Hi Rick,
Thanks for reply

I use 'Informix CLI 2.5' to login to INFORMIX
I have try this days:
TOleAuto():New( 'ADODB.Connection' )
and
TOleAuto():New( 'ADODB.RecordSet' )
WORKING GOOD Thanks for sugestions but that is not what I NEED

I have bigger application based on using ODBC and work good.
Sample i use:
oOdbc := TOdbc():New( sDsn, cUserName, cPassword )
to logon to informix.

I only DONT WANT 'LogOn' window from the driver to be shown
becouse user unwanted can change data from the ODBC driver like database name or host name or ...
That is not huppaning in 16 bit fivewin

Regards,
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: ODBC Problem ?

Posted: Thu Jan 05, 2012 03:10 PM
avista

When you use ODBC you have to register the connection string with each windows client.. hence the ODBC login window you get when you application starts.

ADO uses an OLEDB client for its connection properties. MS SQL Server and MS Access client services are already included in every Windows operating system since Win98 thru Win7 and will be supported at least through Win8.

Unfortunately, databases like IBM and Oracle generally need their own "fat" client to be loaded on each client which ( for me ) is a real burden especially when you are in a large Enterprise environment.

There is not a good answer for you .. because IBM is proprietary and if you go with either option ADO ( oledb ) or ODBC .. you will need to touch each machine or script out a client setup for your workstations.

Rick Lipkin

Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM

Re: ODBC Problem ?

Posted: Wed Jan 11, 2012 04:55 PM

Solved at last !
RICK ... thanks so much to your sugestions they help me 99% :)
I downloaded 'Informix CLI 2.5' driver manual and readed it carefyl how to make connection string.

At last i found that there is a little BUG in class TODBC
METHOD New( cDSN, cUser, cPassword ) CLASS TOdbc
in line:

cConnect += ";PWD=" + ::cPassword

IF you try to connect with DSN,UserName, and Password it is ok
BUT if you try with DRIVER connection string unfotunatly this line add "PWD=" to the end of the connection string
and defined password from connection string is not valid anymore.

For example connection string:

oOdbc := TOdbc():New( "DRIVER={Informix-CLI 2.5 (32 Bit)}; DB=MyDataBase;HOST=MyHost;SERV=MyService;SRVR=MyServer;PRO=MyProtocol;UID=MyName;PWD=MyPass")

in class TODBC Method:New() BECOME

oOdbc := TOdbc():New( "DRIVER={Informix-CLI 2.5 (32 Bit)}; DB=MyDataBase;HOST=MyHost;SERV=MyService;SRVR=MyServer;PRO=MyProtocol;UID=MyName;PWD=MyPass";PWD=)

I simply added 2 lines (Puted that line in IF)

if ! Empty( cPassword )
cConnect += ";PWD=" + ::cPassword
endif

AND work fine.

p.s
ANTONIO probably need to made this change in TODBC class (if readed this) :)

Best regards,

Continue the discussion