Results 1 to 2 of 2

Thread: VB 2010: Need help with Searching and Pulling out records from a specific row

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    6

    VB 2010: Need help with Searching and Pulling out records from a specific row



    I am coding on Visual Basic 2010 and need some help.

    My Access database table has following information:
    FirstName
    LastName
    PhoneNumber

    Basically what I am trying to do is create a Search function where the user will enter a First and Last Name in the search boxes and upon hitting the ''Search'' button the program will look through the database and check if the records exists.

    If the record does exist then I want the Phone number to appear in a separate textbox which is named txtPhoneN.

    I have included the code I use to connect to the Database. I have already managed code the part to Add new record to the database.

    Also I have attached the work I have currently done to this thread


    Code:
        Dim inc As Integer
        Dim MaxRows As Integer
    
        Dim con As New OleDb.OleDbConnection
        Dim dbProvider As String
        Dim dbSource As String
        Dim ds As New DataSet
        Dim da As OleDb.OleDbDataAdapter
        Dim sql As String
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
            dbSource = "Data Source = C:\Users\Hasin\Desktop\computing\DATABASE TEST\AddressBook.mdb"
    
            con.ConnectionString = dbProvider & dbSource
    
            con.Open()
    
            sql = "SELECT * FROM tblContacts"
            da = New OleDb.OleDbDataAdapter(sql, con)
            da.Fill(ds, "AddressBook")
    
            con.Close()
    
            MaxRows = ds.Tables("AddressBook").Rows.Count
            inc = -1
    
        End Sub
    Thanks in advance
    Attached Files Attached Files
    Last edited by hasin_arshad; Sep 20th, 2011 at 07:32 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width