I am trying to get ODBC and Winbatch to work together. I'd swear I had this working but now I'm getting an error on the qConnect function (return code -1). The qAllocEnv and qAllocConnect functions work. I have created a DSN and using the test button it works. I don't see a way to get more debugging information as to why the qConnect fails.
I am talking to a SQL Server database which is on another machine. I am using SQL Server Native Client 11 and a system DSN called TEST.
The IF statement that is "causing" the failure is If (retcode != @qSuccess) && (retcode != @qSuccessInfo) - I don't know where @qSuccess or @qSuccessInfo are defined nor what their values are.
AddExtender("wwodb44i.dll")
;INITIALIZE VARIABLES
MyDataSource="TEST"
MyTableName="tbl_external_restore_dates"
;THIS ALLOCATES A SQL ENVIRONMENT HANDLE
henv = qAllocEnv()
If henv == -1
;THIS RETURNS LAST CODE SET BY LAST SQL FUNCTION
retcode = qLastCode()
Message("qAllocEnv failed", retcode)
Exit
Endif
;ALLOCATES A SQL CONNECTION HANDLE - MAXIMUM
;OF 10 OPEN CONNECTION HANDLES
hdbc = qAllocConnect(henv)
If hdbc == -1
retcode = qLastCode()
Message("qAllocConnect failed", retcode)
Exit
Endif
;CONNECTS TO THE "SAMPLE" DATA SOURCE (with the data source name 'ContactDSN')
retcode = qConnect(hdbc, MyDataSource, "", "")
If (retcode != @qSuccess) && (retcode != @qSuccessInfo)
Message("qConnect failed", retcode)
Exit
Endif