ADO From Fortran - Opening Recordsets?
From: Robin (msrado_at_yahoo.com)
Date: 08/26/04
- Next message: Richard E Maine: "Re: Current Usses for Fortran ??"
- Previous message: Richard E Maine: "Re: What do you prefer: real(8) or double precision and why?"
- Next in thread: Jugoslav Dujic: "Re: ADO From Fortran - Opening Recordsets?"
- Reply: Jugoslav Dujic: "Re: ADO From Fortran - Opening Recordsets?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Aug 2004 11:35:51 -0700
Hello everyone,
I am trying to use ADO from Compaq Visual Fortran v6.1. I have
created a Fortran ADO module with the Fortran Module Wizard and have
some base code that compiles and links. When running the code, my ADO
connection and recordset are created without errors. The connection
opens without errors. But when I try to use the $Recordset_Open
subroutine, I get an unknown status code (-2147352567).
Does anyone know what I'm doing wrong? The code is below:
program main
USE DFWIN
USE DFLIB
USE TestADO
USE DFCOM
USE DFAUTO
USE DFCOMTY
USE RTObjs
implicit none
C
C VARIABLES
INTEGER*4 STATUS
integer*4 aa
integer*4 iStatic
integer*4 iReadOnly
integer*4 iCmd
TYPE (VARIANT) :: vBSTR1
TYPE (VARIANT) :: vCONINT
C INITIALIZE OBJECT POINTERS
CALL INITOBJECTS()
C
C CREATE ADO Connection
CALL COMINITIALIZE(STATUS)
CALL COMCREATEOBJECT("ADODB.Connection", ADOConn, status)
IF(ADOConn.eq.0)then
write(6,*)"Cannot connect to ADO connection object."
goto 999
endif
c
c create ADO recordset
CALL COMCREATEOBJECT("ADODB.Recordset", ADORecSet, status)
if(ADORecSet.eq.0)then
write(6,*)"Cannot connect to ADO recordset object."
goto 999
endif
c
c open ado connection
call $Connection_Open(ADOConn,"Driver={SQL
Server};Server=SERVER
*;Database=DBName;Network=DBMSSOCN;", "User", "password", 0,
*STATUS)
c
c open recordset
C FIRST SET UP BSTR1 = SQL QUERY
CALL VariantInit(vBSTR1)
vBSTR1%VT = VT_BSTR
bstr1 = ConvertStringToBSTR('SELECT * FROM TableName')
vBSTR1%VU%PTR_VAL = bstr1
C NEXT SET UP ADOCONN VARIANT
CALL VariantInit(vCONINT)
vCONINT%VT = VT_I4
vCONINT%VU%LONG_VAL = ADOConn
C
iStatic = adOpenStatic
iReadOnly = adLockReadOnly
iCmd = adCmdTable
call $Recordset_Open(ADORecSet, vBSTR1, vCONINT,
*iStatic, iReadOnly, iCmd, STATUS)
if(status.ne.adStatusOK)then
write(6,*)"Can't open recordset",STATUS
goto 999
else
write(6,*)ADORecSet!Teeth
endif
999 read(5,*)aa
continue
end
Many thanks in advance!
Robin
- Next message: Richard E Maine: "Re: Current Usses for Fortran ??"
- Previous message: Richard E Maine: "Re: What do you prefer: real(8) or double precision and why?"
- Next in thread: Jugoslav Dujic: "Re: ADO From Fortran - Opening Recordsets?"
- Reply: Jugoslav Dujic: "Re: ADO From Fortran - Opening Recordsets?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|