fpineda101
Well-known member
ADO RecordSet RecordCount Property - Resolved
I'm trying this function for a school project. I'm not sure if I am using the correct property. The recordcount property keeps returning as -1 (which probably means False). I test for < 0 in an IF statement and it fails every time. I verified that the data exists, the table name and column name are correct. Can someone provide some insight please?
Below is the code...
Public Function MatchAccountNumber(ByVal value As String) As Boolean
'On Error Resume Next
Dim ConnOracle As ADODB.Connection
Dim Rs1 As ADODB.Recordset
'Dim TCount As Integer
Trim(value)
ConnOracle = New ADODB.Connection
ConnOracle.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=CIT455;User ID=scott;Password=tiger;"
ConnOracle.Open()
Rs1 = New ADODB.Recordset
SQL = "select account_number from account where account_number = " & value
Rs1 = ConnOracle.Execute(SQL) 'as ADODB.RecordSet;
'TCount = CInt(Rs1.GetRows(Rs1.RecordCount))
If Rs1.RecordCount > 0 Then
MsgBox("Match Found!", MsgBoxStyle.OKOnly, "Account match made")
MatchAccountNumber = True
Else
MsgBox("Match Not Found!", MsgBoxStyle.OKOnly, "Account match not made")
MatchAccountNumber = False
End If
End Function
Thanks in advance for you help!
fpineda101
I'm trying this function for a school project. I'm not sure if I am using the correct property. The recordcount property keeps returning as -1 (which probably means False). I test for < 0 in an IF statement and it fails every time. I verified that the data exists, the table name and column name are correct. Can someone provide some insight please?
Below is the code...
Public Function MatchAccountNumber(ByVal value As String) As Boolean
'On Error Resume Next
Dim ConnOracle As ADODB.Connection
Dim Rs1 As ADODB.Recordset
'Dim TCount As Integer
Trim(value)
ConnOracle = New ADODB.Connection
ConnOracle.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=CIT455;User ID=scott;Password=tiger;"
ConnOracle.Open()
Rs1 = New ADODB.Recordset
SQL = "select account_number from account where account_number = " & value
Rs1 = ConnOracle.Execute(SQL) 'as ADODB.RecordSet;
'TCount = CInt(Rs1.GetRows(Rs1.RecordCount))
If Rs1.RecordCount > 0 Then
MsgBox("Match Found!", MsgBoxStyle.OKOnly, "Account match made")
MatchAccountNumber = True
Else
MsgBox("Match Not Found!", MsgBoxStyle.OKOnly, "Account match not made")
MatchAccountNumber = False
End If
End Function
Thanks in advance for you help!
fpineda101
Last edited: