Results 1 to 3 of 3

Thread: Doubt in storing values in database table

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2002
    Location
    chennai
    Posts
    20

    Doubt in storing values in database table

    I store the listbox values in the database table using the below coding:


    for i= 0 to list1.listcount-1
    rs.addnew
    rs![fnam]=list1.list(i)
    rs.update
    next i

    The datas are added to the table. But if i run the program second time, the same values are again added to the table. If i run second time, the values which are added to the table(at first running) must be cleared and the values should be added freshly.
    How to do this using vbcoding. Please help me.

  2. #2
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    for i= 0 to list1.listcount-1
    ' Attempt to find the entry.
    rs.Find "fnam = '" & list1.list(i) & "'"
    ' Check if the entry was already found.
    If Rs.Eof then
    rs.addnew
    rs![fnam]=list1.list(i)
    rs.update
    end if
    next i
    Leather Face is comin...


    MCSD

  3. #3
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    alternativly you could just delete the contents of the table.

    since you are going to be going through all of the listitems and searching for each one, you may as well just delete all existing records in the table. should be faster too.

    i.e.

    connection.Execute "DELETE * FROM tablename;"
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

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