I can connect fine using the following code:
Code: Select all
/*** Set connection string ***/
cConnect := "DBE=ODBCDBE"
cConnect += ";DRIVER=AdagioDataSourceDriver"
cConnect += ";COLUMNS=COMMON"
cConnect += ";DBDIRECTORY=C:\Softrak\ODBCV2\SAMDATA"
cConnect += ";DBQ=C:\Softrak\ODBCV2\SAMDATA\SAM"
cConnect += ";DBFILTER=ar9*"
cConnect += ";DBSELELECTOR=SAM"
cConnect += ";NAMES=SHORT"
cConnect += ";USERID=SYS"
cConnect += ";PASSWORD=SYS"
cConnect += ";RAWPASSWORD=1"
cConnect += ";TABLESALL=FALSE"
/*** Create dacsession ***/
oSession := DacSession():New(cConnect)
/*** Test for connection success ***/
IF ! oSession:IsConnected()
DC_Winalert("Connection failed")
wtf "ERROR code: " + AllTrim(Str(oSession:GetLastError())), ;
"Description: " + AllTrim(oSession:GetLastMessage()) pause
RETURN NIL
ENDIF
/*** Success message ***/
DC_Winalert("Connection to server established")
Using DacSession's :ExecuteQuery() or :ExecuteStatement() like the following:
Code: Select all
oSession:ExecuteQuery('SELECT Name FROM ar92acst')
When I try accessing the data using the commands USE or SQL like the following:
Code: Select all
USE 'ar92acst'
SQL "SELECT Name FROM ar92acst"
I tried the same thing in Python, and it works:
Code: Select all
import pyodbc
# Create statement to connect to driver
driverConnect = 'DRIVER={AdagioDataSourceDriver}' + \
';COLUMNS=COMMON' + \
';DBDIRECTORY=C:\\Softrak\\ODBCV2\\SAMDATA' + \
';DBQ=C:\\Softrak\\ODBCV2\\SAMDATA\\SAM' + \
';DBFILTER=ar9*' + \
';DBSELELECTOR=SAM' + \
';NAMES=SHORT' + \
';USERID=SYS' + \
';PASSWORD=SYS' + \
';RAWPASSWORD=1' + \
';TABLESALL=FALSE'
# Connect to odbc using driver
#connection = pyodbc.connect(driverConnect)
# Get cursor
cursor = connection.cursor()
# Execute select statement
cursor.execute("SELECT Name FROM ar92acst")
row = cursor.fetchone()
while row:
print(row[0])
row = cursor.fetchone()