none
search an access db in vb.net without sql RRS feed

  • Question

  • i hv an access database "employee" having table "table1". i take a variable a, now whn i enter a=4, i want d record where "id" column consists 4 shud get displayed......datatype of id column is autonumber, this is d code:

    Dim a AsInteger
    Dim b AsInteger
    Dim c AsInteger
    Dim d AsInteger
    b = 0
    d = 1
    a = InputBox("abc", "xyz")
    Me.BindingContext(DataSet11, "table1").Position = 0
    c = Val(DataSet11.Table1.Count)
    DoWhile d <= c
    If Fix(DataSet11.Table1.idColumn) <> a Then
    Me.BindingContext(DataSet11, "table1").Position = Me.BindingContext(DataSet11, "table1").Position + 1
    Else
    b = 1
    ExitDo
    EndIf
    d = d + 1
    Loop
    If b = 0 Then
    MsgBox("Employee number does not exist")
    EndIf

    wht shud i put in d braces of fix function,do i even need to use any function.

    following is an equivalent code in vb6 :

    b = 0
    a = InputBox("Enter the employee number to be displayed", "Employee number", 0)
    ado.Recordset.MoveFirst
    Do While ado.Recordset.EOF = False
    If ado.Recordset.Fields(0) <> a Then
    ado.Recordset.MoveNext
    Else
    b = 1
    Exit Do
    End If
    Loop
    If b = 0 Then
    MsgBox ("Employee number does not exist")
    End If

    Saturday, June 20, 2009 9:55 AM

Answers