Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    find the same value in rset... (2000 and vb 6.0)

    With tipical ado conn and rset....
    Admit have a var1 filled "123456" , var2 filled "AAAAAAA" , var3 filled "DDDDDDD" , var4 filled "GGGGGGG" in table "mytable" in this table have in rset filled with a list of value:

    PROVA1
    123456
    789456
    145879
    ........
    PROV2
    AAAAAAA
    BBBBBBBB
    CCCCCCC
    ........
    PROVA3
    DDDDDDD
    EEEEEEEE
    FFFFFFFF
    ........
    PROVA4
    GGGGGGG
    HHHHHHH
    IIIIIIII
    ......

    is possible to loop in all 3 rset PROVA2, PROVA3,PROVA4 based index in PROVA1 and the matching of 3 rset is not is equal update all 3 rset with new value if the 3 rset are equal skip operation...

    in this case skip the operaion of update rset...

    Hope understnd me;-)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    I'm sorry, I don't understand your description. Do you have 3 recordsets or 3 fields? And what exactly do you want?
    Please try to explain more clearly.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    PROVA1, PROVA2....PROVA4 are the name of field.
    PROVA1 is the filed can contain the var1 filled "123456"
    Now....
    Existis "123456" in PROVA1?, if yes compare if the var2 filled with "AAAAAAA" in filed PROVA2 , var3 filled with "DDDDDDD" in filed PROVA3, var4 filled with "GGGGGGG" in filed PROVA4 all 3 rset have the same value, no action

    Existis "123456" in PROVA1?, if yes compare if the var2 filled with "AAAAAAA" in filed PROVA2 , var3 filled with "DDDDDDD" in filed PROVA3, var4 filled with "GGGGGGG" in filed PROVA4 all 3 rset not have the same value, update the rset with the value stored in var is the case of secaond line in image attached

    In effect compare, based the idex in PROVA1, block of var with block of rset

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    So if the value of PROVA1 = var1, the value of PROVA2 should ALWAYS be var2 etc.? If so, you don't need to loop, you can use an update statement:
    <code>
    Dim strSQL As String
    strSQL = UPDATE [elenco indirizzi] SET PROVA2=" & Chr(34) & var2 & Chr34) & _
    ", PROVA3=" & Chr(34) & var2 & Chr34) & ", PROVA4=" & Chr(34) & var4 & Chr34) & _
    " WHERE PROVA1=" & Chr(34) & var1 & Chr(34)
    cnn.Execute strSQL
    </code>
    where elenco indirizzi is the name of the table.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    KISS!!! <img src=/S/artist.gif border=0 alt=artist width=34 height=29>
    Sorry for my english...

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    hummmmmmmmmm.
    but the query compare if value of var are the same in fileds?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    If I understood your description correctly, that is not necessary.

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    ok!
    is the SET command to make all?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    SET only specifies the fields that will be updated and the new values.
    The WHERE part specifies which records will be updated.

  10. #10
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    ... about SET if the index PROVA1 not existis in table how to?
    For example PROVA1 is a new record...

  11. #11
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    in other case have error in sql... <img src=/S/aflame.gif border=0 alt=aflame width=16 height=16>

    SQL1 = Empty
    SQL1 = "UPDATE DATI SET PROVA2 = '" & MERCATO_2 & "', PROVA3 = '" & MERCATO_3 & "', PROVA4 = '" & MERCATO_4 & "' , PROVA5 = '" & MERCATO_5 & "' , PROVA6 = '" & MERCATO_6 & "' , PROVA7 = '" & MERCATO_7 & "' , PROVA8 = '" & MERCATO_8 & "' , PROVA9 = '" & TEST_DATA & "' , PROVA10 = '" & DATA_CORRENTE & "' , PROVA11 = '" & NOMINATIVO & "' WHERE PROVA1 = " & MERCATO_1
    CNSQL.Execute (SQL1)

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    If there is no record with the specified value, an update query won't do anything. You'd have to run an append query.

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    Is Prova1 a number field, and are ALL other fields text fields?

  14. #14
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    No all var are string text... and fileds are setting nvarchar(50)
    only fileds prova9 AND prova10 are date

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find the same value in rset... (2000 and vb 6.0)

    If PROVA1 is a text field, you should change
    <code>
    ... & "' WHERE PROVA1 = " & MERCATO_1
    </code>
    to
    <code>
    ... & "' WHERE PROVA1 = '" & MERCATO_1 & "'"</code>

Page 1 of 3 123 LastLast

Posting Permissions

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