Results 1 to 3 of 3

Thread: ADO update confused!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29
    How can I just move thought a recordset and update records which meet my criteria, it updates the whole file.

    This is what I am doing.




    Dim cn1 As ADODB.Connection
    Dim rs1 As ADODB.Recordset

    Set cn1 = New ADODB.Connection
    cn1.ConnectionString = "Provider=MSDASQL.1;" _
    & "Persist Security Info=False;" _
    & "DSN=Visual FoxPro Tables;" _
    & "UID=;" _
    & "PWD=;" _
    & "SourceDB=c:\ado;" _
    & "SourceType=DBF;" _
    & "Exclusive=No;" _
    & "BackgroundFetch=Yes;" _
    & "Collate=Machine;" _
    & "Null=Yes;" _
    & "Deleted=Yes;"

    If cn1.State = 1 Then
    cn1.Close
    Else
    cn1.Open
    End If
    cn1.CursorLocation = adUseClient

    Set rs1 = New ADODB.Recordset
    rs1.Open "SELECT * FROM test", cn1, adOpenKeyset, adLockOptimistic

    For x = 1 To rs1.RecordCount
    With rs1
    !Name = "I know"
    .MoveNext
    End With
    Next x

    rs1.Close
    cn1.Close

  2. #2
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Worldwide in the Sun
    Posts
    566
    Why going to the full table.

    Use a WHERE clausule in the SELECT statement.

    rs1.Open "SELECT * FROM test WHERE fieldname = '" & yourcriteria & "' ",cn1, adOpenKeyset, AdLockOptimistic

    Now you have only those records matching your criteria.

    cheers
    Ray
    Ray

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29

    Nth Select program

    Because I built a nth select program, say if I have 100 records and I only want to choose 10 I create a flag field move throught the records and with a fomula calculate 10 out of the 100 and mark the flag field.

    I'm having a hard time because when I use this

    rs!field = "K"
    rs.update
    rs.movenext


    it updates my whole file.

    Bruno

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