Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,573 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,889 people online right now. Registration is fast and FREE... Join Now!




Run Time Error while displaying records from database to listview

 
Reply to this topicStart new topic

Run Time Error while displaying records from database to listview

emkaye
13 May, 2008 - 07:09 PM
Post #1

D.I.C Head
**

Joined: 12 Aug, 2007
Posts: 54


My Contributions
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..
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:03AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month