Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dim Con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim s As String
Private Sub Command1_Click()
Con.Open s
rs.Open "SELECT * FROM TRAIN WHERE FROM LIKE '" & Combo1.Text & "%' AND TO LIKE '" & Combo2.Text & "%' ", Con, adOpenDynamic, adLockOptimistic
If rs.EOF = False Then
Text3.Text = rs(0)
Text4.Text = rs(1)
Text6.Text = rs(2)
Text7.Text = rs(3)
Text5.Text = rs(4)
End If

rs.Close
Con.Close
End Sub




This is correct or not.... i have a problem with 1st record is displayed remaining 9 records are not displayed in the output.
please help me
Posted

VB
Dim Con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim s As String

Private Sub Command1_Click()
Con.Open s
rs.Open "SELECT * FROM TRAIN WHERE FROM LIKE '" & Combo1.Text & "%' AND TO LIKE '" & Combo2.Text & "%' ", Con, adOpenDynamic, adLockOptimistic

While Not rs.EOF
      Text3.Text = rs(0)
      Text4.Text = rs(1)
      Text6.Text = rs(2)
      Text7.Text = rs(3)
      Text5.Text = rs(4)
      rs.MoveNext
Wend


Note : On the UI you will get the values of last records as you are over writing the Text.Text with new record in each iteration.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900