Searching a record - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Searching a record

mehuldhokamehuldhoka Posts: 1Member
hi..this is mehul here..
i have been developng a s/w for an enterprise using vb6.0 and ACCESS.
can any body tell me the code to search a specific record in the table and view it in vb(through vb)...????

Comments

  • lionblionb Posts: 1,688Member ✭✭
    : hi..this is mehul here..
    : i have been developng a s/w for an enterprise using vb6.0 and ACCESS.
    : can any body tell me the code to search a specific record in the
    : table and view it in vb(through vb)...????
    :
    :
    You have to use ADODB object to connect to he database and do data manipulation such as retrieving/inserting/updating. To search specific record you have to use SQL statement like this
    [code]SELECT MyRecord FROM MyTable WHERE NyRecordID = 100[/code]
    To get ADODB object you have to refer to Microsoft ActiveX Data Object Laibrary 2.1 or later (later is better)

    [code]
    Dim cn as new ADODB.Connection
    Dim rs as new ADODB.Recordset
    Dim strConn as String 'connection string
    Dim strSQL as String
    Dim strRecord as String

    strConn="Provider=Microsoft.Jet.OLEDB.4.0;
    DataSource=C:Test.mdb;
    Persist Security Info=False"

    cn.Open strConnect
    strSQL ="SELECT MyRecord FROM MyTable WHERE NyRecordID = 100"

    rs.Open strSQL,cn

    Do until rs.EOF
    strRecord = rs.Fields("MyRecord").Value
    rs.MoveNext
    Loop
    [/code]
Sign In or Register to comment.