search records in mdb using vb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yojeiramnj
    New Member
    • Sep 2007
    • 4

    search records in mdb using vb

    please help... i have a vb program which needs to search for employee name inside empmas.mdb, specifically empmas table. the user will input the idnumber on a textbox and from that it will search the name of the employee and display it in a label in my vb program.

    all i have is this:


    Dim db As Database

    Dim rs As Recordset

    Dim SQLString As String

    Set db = OpenDatabase("C :\empmas.mdb")
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try to search using SQL query .

    Frame the query dynamically on user input

    Comment

    • yojeiramnj
      New Member
      • Sep 2007
      • 4

      #3
      i'm sorry but i don't know how... i haven't used sql... i'm only a beginner in programming... i've read about SELECT in sql but i haven't understood the concept...

      i tried this:
      strSQLString = SELECT * FROM empmas WHERE e_empno like '*" & txtEmpNum.text & "*'";

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        Originally posted by yojeiramnj
        please help... i have a vb program which needs to search for employee name inside empmas.mdb, specifically empmas table. the user will input the idnumber on a textbox and from that it will search the name of the employee and display it in a label in my vb program.

        all i have is this:


        Dim db As Database

        Dim rs As Recordset

        Dim SQLString As String

        Set db = OpenDatabase("C :\empmas.mdb")
        -------------------
        Hi m8, im new to vb myslef but i have managed to successfully do something simular to this.

        Dim Cmd2 As OleDb.OleDbComm and
        Dim Con2 As OleDb.OleDbConn ection
        Dim Sql2 As String = Nothing
        Dim Reader2 As OleDb.OleDbData Reader
        Dim ComboRow2 As Integer = -1
        Dim Columns2 As Integer = 0
        Dim Category2 As String = Nothing


        Con2 = New OleDb.OleDbConn ection("Provide r=Microsoft.Jet .OleDb.4.0;data source=FAQs.mdb ")
        Sql2 = "SELECT Question FROM tblQuestion " & _
        "WHERE Category_Id = '" & strChosenQuesti on & "'"
        Cmd2 = New OleDb.OleDbComm and(Sql2, Con2)
        Con2.Open()

        Reader2 = Cmd2.ExecuteRea der()
        While Reader2.Read()
        For Columns2 = 0 To Reader2.FieldCo unt - 1
        Category2 = Reader2.Item(Co lumns2) 'READ COLUMN FROM DATABASE
        Next
        cboQuestion.Ite ms.Add(Category 2)
        ComboRow2 += 1
        End While
        Con2.Close()

        c if this helps...

        Comment

        Working...