A run time error occured when i tried to display records from my database to a listview. Below is my code:
CODE
Dim TallyRS As New ADODB.Recordset
Private Sub CMDsEARCH_Click()
Dim TallyInput As String
Dim TallyResult As String
Dim LS As ListItem
TallyInput = InputBox("Enter search below. It could be either by repat no or by any type of field you wish to search.")
TallyResult = "select * from tblRepat where ACTION_TAKEN = '" & TallyInput & "' OR RECORD = '" & TallyInput & "' OR POSITION = '" & TallyInput & "' or LAST_NAME = '" & TallyInput & "' "
Set TallyRS = myConn.Execute(TallyResult)
If TallyRS.EOF = True Then
MsgBox "Record does not exist!"
Else
MsgBox "Record found!"
LVreS.ListItems.Clear
Do Until TallyRS.EOF
Set LS = LVreS.ListItems.Add(, , TallyRS(0))
' Set LS = LVreS.ListItems.Add(, , TallyRS(0))
LS.SubItems(1) = TallyRS(1) & ""
LS.SubItems(2) = TallyRS(2) & ""
LS.SubItems(3) = TallyRS(3) & ""
LS.SubItems(4) = TallyRS(4) & ""
LS.SubItems(5) = TallyRS(6) & ""
LS.SubItems(6) = TallyRS(7) & ""
LS.SubItems(7) = TallyRS(8) & ""
LS.SubItems(8) = TallyRS(9) & ""
LS.SubItems(9) = TallyRS(10) & ""
LS.SubItems(10) = TallyRS(11) & ""
LS.SubItems(11) = TallyRS(13) & ""
LS.SubItems(12) = TallyRS(14) & ""
TallyRS.MoveNext
Loop
End If
End Sub
when i tried including the attributes ACTION_TAKEN, LAST_NAME, & RECORD. the run time error is not occuring.but when i added the attribute POSITION, the run time error occured. Its says that
Method 'Execute' of object '_Connection' failed.
is there anything wrong with my code or my database?
pls help
tnx..