SqlSelect error with DB2 Driver ODBC

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
Cyril

SqlSelect error with DB2 Driver ODBC

Post by Cyril »

Hi

I have a SQL error when I want to initiate a SQLSelect with a SQLConnection on DB2 database

This code perform correctly in VO but not in XSharp with this error:
[IBM][CLI Driver][DB2/AIX64] SQL30090N Opération incorrecte pour l'environnement d'exécution d'application. Code anomalie = "22". SQLSTATE=25000

Code: Select all

FUNCTION Start() AS INT
	LOCAL oDbDB2I		AS sqlConnection
	LOCAL oSqlSelect	AS SQLSelect

	? "DB2 connection testing"                      
	
  	oDbDB2I := sqlConnection{"DNS_NAME", "USER", "PASSWORD"}     
  	IF !IsNil(oDbDB2I:ErrInfo)    
  		? "Erreur Connection"
  		? oDbDB2I:ErrInfo:ErrorMessage 
  	ENDIF
	oSqlSelect := SqlSelect{"SELECT comm_no, demarch_car_no, f_valid_dat_ca FROM MVSDB2DET.VACMANRX", oDbDB2I}    
	IF oSqlSelect:Execute()
		? "requete OK"
	ELSE
		? oSqlSelect:ErrInfo:ErrorMessage
		? "requete KO"
	ENDIF  	
	
	oSqlSelect:Close()
	oDbDB2I:Disconnect()          
Could you help me please ?

Thanks
Cyril
User avatar
robert
Posts: 4558
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: SqlSelect error with DB2 Driver ODBC

Post by robert »

Cyril,
Which version of VO were you using?
There were changes in the SQL classses between VO 2.7 and VO 2.8.
Our classes are compatible with VO 2.8.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Cyril

Re: SqlSelect error with DB2 Driver ODBC

Post by Cyril »

Hi

We use 2.7 VO version :(
Is there a solution to fix our issue ?

Thank you
Cyril
User avatar
robert
Posts: 4558
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: SqlSelect error with DB2 Driver ODBC

Post by robert »

Cyril,
Try this

Code: Select all

oDbDB2I := sqlConnection{"DNS_NAME", "USER", "PASSWORD"}     
  	IF !IsNil(oDbDB2I:ErrInfo)    
  		? "Erreur Connection"
  		? oDbDB2I:ErrInfo:ErrorMessage 
  	ENDIF
  	// The Cursor options are SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC, SQL_CUR_USE_DRIVER
  	// VO 2.7 used SQL_CUR_USE_ODBC. VO 2.8 and X# use SQL_CUR_USE_IF_NEEDED
        oDbDB2I:OdbcCursors := SQL_CUR_USE_ODBC  

        oSqlSelect := SqlSelect{"SELECT comm_no, demarch_car_no, f_valid_dat_ca FROM MVSDB2DET.VACMANRX", oDbDB2I}    
	IF oSqlSelect:Execute()
		? "requete OK"
	ELSE
		? oSqlSelect:ErrInfo:ErrorMessage
		? "requete KO"
	ENDIF  	
	
	oSqlSelect:Close()
	oDbDB2I:Disconnect()         
	
XSharp Development Team
The Netherlands
robert@xsharp.eu
Cyril

Re: SqlSelect error with DB2 Driver ODBC

Post by Cyril »

Realy realy thanks !!

it's ok with this option

just a little correction for futur readers, we can't change option after open connection so we have to do this

Code: Select all

oDbDB2I := sqlConnection{}     

  	// The Cursor options are SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC, SQL_CUR_USE_DRIVER
  	// VO 2.7 used SQL_CUR_USE_ODBC. VO 2.8 and X# use SQL_CUR_USE_IF_NEEDED
        oDbDB2I:OdbcCursors := SQL_CUR_USE_ODBC  
        
	oDbDB2I:oDbDB2I:connect("DNS_NAME", "USER", "PASSWORD")
	
  	IF !IsNil(oDbDB2I:ErrInfo)    
  		? "Erreur Connection"
  		? oDbDB2I:ErrInfo:ErrorMessage 
  	ENDIF
Post Reply