Results 1 to 4 of 4

Thread: [RESOLVED] referesh SQL database after updating

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2008
    Location
    selangor, Malaysia
    Posts
    71

    Resolved [RESOLVED] referesh SQL database after updating

    hi guys whut i try to do here is to refresh SQL database so that new data that have been enter before will be display in combo box. The problem is i do not know how..


    Code:
    sqlStr = "select * from tblMEmployee where EmpNo = '" & txbEmpNo.Text & "'"
    myRecSet.Open sqlStr, MyConnObj, adOpenKeyset
    myRecSet.Refresh '--Error:member or data member not found
    myRecSet.Close
    help me plz..

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: referesh SQL database after updating

    You need to replace that line with code that fills the combobox - if you don't know how, see the "Classic VB - ADO" section of the FAQs at the top of this forum.


    I have deleted the duplicates of this thread - please post each question only once.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2008
    Location
    selangor, Malaysia
    Posts
    71

    Re: referesh SQL database after updating

    ok sorry si

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: referesh SQL database after updating

    Try
    Code:
    sqlStr = "select EmpNo from tblMEmployee where EmpNo = '" & txbEmpNo.Text & "'"
    myRecSet.Open sqlStr, MyConnObj, adOpenKeyset
    Combo1.Clear
    Do While Not myRecSet.EOF
         Combo1.Additem myRecSet(0)
         myRecSet.MoveNext
    Loop
    myRecSet.Close
    Set myRecSet = Nothing
    Please note I changed * to the name of the field. If all you are after is one field in your table there is no need, nor does it make any sense, to select ALL fields in your table. When writing a SELECT query, just list the fields that you actually need for that particular query.

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