Code for search button RRS feed

  • Question

  • I have been coding for the past 24 hours now, the code below works and searches the records in the database (MS Access), but it only return the first record in the database in the first row. Where am i going wrong?

            con.Open("provider = Microsoft.ACE.OLEDB.12.0; Data source=Project_3.accdb")
            rs.Open("select * from LoT", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic, 1)

            If rs.RecordCount = 0 Then
                MsgBox("Record Not Found")
                txtid.Text = rs("LOT_ID").Value
                txttyp.Text = rs("LOT_Type").Value
                txtprc.Text = rs("LOT_Price").Value

                End If

    Sunday, March 26, 2017 7:57 AM

All replies

  • It looks very much to VBA (Excel) programming. 

    This forum is for VB.Net


    Sunday, March 26, 2017 8:20 AM
  • Hi Levite17,

    Based on your description, I'm not sure which language you use, Can you tell me if you use VB.NET to create your project?


    Best Regards,

    Cherry Bu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, March 27, 2017 2:36 AM
  • I am using ADO.NET to create interaction between the form in VB and the access database.


    Best Regards,


    Monday, March 27, 2017 10:25 AM