ODBC Problem ?

ODBC Problem ?

Postby avista » Thu Dec 29, 2011 4: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 ?
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: ODBC Problem ?

Postby Rick Lipkin » Thu Dec 29, 2011 6: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
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: ODBC Problem ?

Postby avista » Fri Dec 30, 2011 8:09 am

Hi Rick,
Thanks for reply

Loging to INFORMIX

Regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: ODBC Problem ?

Postby Rick Lipkin » Fri Dec 30, 2011 1: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: Select all  Expand view  RUN

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


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

Re: ODBC Problem ?

Postby avista » 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,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: ODBC Problem ?

Postby Rick Lipkin » Thu Jan 05, 2012 3: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

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

Re: ODBC Problem ?

Postby avista » Wed Jan 11, 2012 4: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,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 100 guests