01-27-2009, 12:11 AM
I am getting the error when running the below code.
'The connection can't be used to perform this operation. It is either closed or invalid in this context'.
Please help with the below code.
'The connection can't be used to perform this operation. It is either closed or invalid in this context'.
Please help with the below code.
Code:
'Connecting to Oracle
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set Conn_Obj = CreateObject("ADODB.Connection")
Set Rec_Obj = CreateObject("ADODB.Recordset")
Conn_Obj.Open "DRIVER= Oracle in OraClient10g_home1;SERVER = oracle_server;Data Source = FITN;UID= user1;PWD= passwd"
Rec_Obj.CursorLocation = adUseClient
Rec_Obj.Open "select ir.cusip from market.instrument ir where ir.cusip ='20172KC78' adOpenStatic,adLockOptimistic"
While not(Rec_Obj.EOF)
Msgbox "Result " & Rec_Obj.Fields.Item("cusip")&vbCrLf
Rec_Obj.MoveNext
Wend
Rec_Obj.Close
Conn_Obj.Close
Set Rec_Obj = Nothing
Set Conn_Obj = Nothing
Msgbox "It is a success"