I’m trying to get data from an centura sqlbase server via ODBC. Connection succeeds, but the result.execute fails.
Here’s (most of) my code:
=======================================
… dim variables …
Set qry.Connection = con
qry.sql = sqlstr
Set result.query = qry
'Verbindung zu ADIS
dataSource = “SOURCENAME”
userName = “USER”
password = “PW”
tabelle = “AMES_1”
sqlstr = " SELECT * FROM AMES_1 WHERE KDNR = ‘00001805’"
If Not con.ConnectTo(dataSource, userName, password) Then
Messagebox "Could not connect to " & dataSource
Exit Sub
End If
’ – here I test for table names, they return fine – including AMES_1
’ – so the connection is up, and I can “see” the tables
tables = con.ListTables()
msg = dataSource & " contains the following tables:" & Chr(10)
For n% = Lbound(tables) To Ubound(tables)
msg = msg & Chr(10) & tables(n%)
Next
Messagebox msg, "Tables for " & dataSource
’ – now I try my SQL Query:
result.Execute
If Not result.IsResultSetAvailable Then
Messagebox “ODBCResultSet.execute eror”
con.Disconnect
Exit Sub
End If
’ – and I always runs into the error message
con.Disconnect
=======================================
When I debug the code and look into the variables, qry.Connection is empty (doesn’t show any value) – but I think this is normal?
So is anything wrong in my sql statement, or must there be an error in the ODBC connection (and drivers).
I can query data with excel from this (sqlbase) server, from the AMES_1 table, of course with the same username/pw.
Thanks for any help in advance
Uwe