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

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.