I am having trouble returning data from an Oracle table...
I can get data with the following:
But I can NOT get data back if I change my SQL toCode:Option Explicit
Public adoDWConnection As ADODB.Connection
Public adoDWRecordset As ADODB.Recordset
Private Sub Command1_Click()
OpenDWConnection
MsgBox GetBalance(Me.txtAccount)
End Sub
Sub OpenDWConnection()
Dim strConnection As String
Set adoDWConnection = New ADODB.Connection
strConnection = "Provider=MSDASQL.1;Data Source=DATA_WAREHOUSE"
adoDWConnection.Open strConnection, "MyLoginID", "MyPassword"
End Sub
Function GetBalance(strAcctNbr As String) As String
Set adoDWRecordset = New ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT acct_status_id from adhoc_view.curr_acct_status where acct_nbr = '" & strAcctNbr & "'"
adoDWRecordset.Open strSQL, adoDWConnection, adOpenDynamic
GetBalance = adoDWRecordset![acct_status_id]
adoDWRecordset.Close
End Function
and change the return toCode:select acct_nbr, bill_amt from adhoc_view.curr_bill where acct_nbr = '" & strAcctNbr & "'"
What I get is error number 3021: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.Code:GetBalance = adoDWRecordset![bill_amt]
The SQL returns a valid record if I run it thru TOAD, so I know it works.
Why would this table not return results?
Thanks!
