Friday, April 17, 2009

ADO Usage Sample

'Function to connect and retrieve data from tables(from Oracle)

***************************************************************************
Call createDBCon()
Call execDB()
Call verifyDBdata()
Call closeDB()

***************************************************************************

strQuery ="Select * from "

Function createDBCon()
reporter.ReportEvent micDone,"Connecting to Database",""
Set dbCon = CreateObject("ADODB.Connection")
dbCon.Open("DSN=IORA0001;UID=TDAMGR;PWD=TDAMGR123#;DBQ=IORA0001;DBA=W;APA=T;EXC=F;FEN=T;QTO=F;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;")
End Function

'**********************************************************
'Execute the query passed using the DB obj created previously
'**********************************************************

Function execDB()

iRowCount = 0
set rs=dbCon.execute(strQuery1)
Set rs = Nothing

End Function

Function closeDB()
reporter.ReportEvent micDone,"Closing Database Connection",""
dbCon.close
End Function

'**********************************************************
'verify the db data after the loader process with the intial values
'**********************************************************

Function verifyDBdata()
Dim index
Dim iRowCount
iRowCount =0
set rs=dbCon.execute(strQuery2)
fldCnt= rs.fields.count
Do While Not rs.EOF
For i= 0 To fldCnt-1
dbOutput(i) = trim(rs.Fields(i).Value)
iRowCount = iRowCount+1
Next
rs.MoveNext
Loop

End Function



'Refer to Useful Links section for more information

No comments: