Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Copy Recordset and save it back to Database


Message #1 by "Grau Kilian (rds)" <rds@a...> on Fri, 14 Feb 2003 11:40:48 +0100




Copy Recordset and save it back to Database



Hi All,


I like to Copy 20 or more records from a sql server table back into the same table


The Sql Table:
AutoID  --> automatic value
Name            --> string
FristName       --> string
Credit  --> Long


And now i want to know the simplest way to dublicate all records with the new Credit 40 and maybe a secord field
Is there a way to copy all entrys with one or two lines ? (recordset.clone )


cheers Kilian


I did use the follow Code this is copy only the first record and not all of the recordset:


    For i = 1 To rsTmpNewMand.Fields.Count - 1
        If IsNull(rsTmpNewMand(i).Value) = False Then
            If rsTmpNewMand.Fields(i).Type = 11 Then
                If rsTmpNewMand(i).Value = True Then
                    tmpArray(i) = 1
                Else
                    tmpArray(i) = 0
                End If
            Else
                tmpArray(i) = rsTmpNewMand(i).Value
            End If
        End If
    Next
    
    rsTmpNewMand.AddNew
    
    For i = 1 To rsTmpNewMand.Fields.Count - 1
        If Not tmpArray(i) = "" Then
            rsTmpNewMand(i).Value = tmpArray(i)
        End If
    Next


    rsTmpNewMand("Credit").Value = 40





  Return to Index