Hi,
I wonder if somebody knows: Is there a way to append records of a recordset simply into an another recordset (table)? (ADO).
I have a read-only database. I want to insert some (120-100) records all at once from this into a table of the client.
***************************************************************************
an option f. e. : getrows
...
Set rst = cnn.Execute("SELECT MERESEK.* FROM MERESEK WHERE [MERESEK].[ID]>= " & lIDMax - Val(Forms![Main]![txtNumRecords]))
rstTarget.CursorType = adOpenKeyset
rstTarget.CursorLocation = adUseClient
rstTarget.LockType = adLockOptimistic
rstTarget.Open "MERESEK", CurrentProject.Connection
myArr = rst.GetRows
For i = 1 To rst.Fields.Count
str1 = str1 & rst.Fields(i - 1).Name
If i <> rst.Fields.Count Then str1 = str1 & ", "
Next i
For lIndex = 0 To rst.RecordCount - 1
For j = 0 To rst.Fields.Count - 1
If IsNull(myArr(j, lIndex)) Then
str2 = str2 & "Null"
Else
str2 = str2 & Chr(39) & myArr(j, lIndex) & Chr(39)
End If
If j <> rst.Fields.Count - 1 Then str2 = str2 & ", "
Next j
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "INSERT INTO MERESEK (" & str1 & " Values (" & str2 & ""
cmd.CommandType = adCmdText
cmd.Execute
str2 = ""
Next lIndex
...
***************************************************************************
It works, but it's too slow. (with 800 rec ~ 25 sec)
It worked thus far faster with a simple INSERT INTO command (bellow), but now the permissions are limited.
DoCmd.RunSQL "INSERT INTO MERESEK " & _
"SELECT MERESEK.* " & _
"FROM MERESEK IN " & Chr(34) & strAnalMDBPath & Chr(34) & _
"WHERE [MERESEK].[ID]>= " & lIDMax - Val(Forms![Main]![txtNumRecords])
What to do? Now I am in despair. ide
I wonder if somebody knows: Is there a way to append records of a recordset simply into an another recordset (table)? (ADO).
I have a read-only database. I want to insert some (120-100) records all at once from this into a table of the client.
***************************************************************************
an option f. e. : getrows
...
Set rst = cnn.Execute("SELECT MERESEK.* FROM MERESEK WHERE [MERESEK].[ID]>= " & lIDMax - Val(Forms![Main]![txtNumRecords]))
rstTarget.CursorType = adOpenKeyset
rstTarget.CursorLocation = adUseClient
rstTarget.LockType = adLockOptimistic
rstTarget.Open "MERESEK", CurrentProject.Connection
myArr = rst.GetRows
For i = 1 To rst.Fields.Count
str1 = str1 & rst.Fields(i - 1).Name
If i <> rst.Fields.Count Then str1 = str1 & ", "
Next i
For lIndex = 0 To rst.RecordCount - 1
For j = 0 To rst.Fields.Count - 1
If IsNull(myArr(j, lIndex)) Then
str2 = str2 & "Null"
Else
str2 = str2 & Chr(39) & myArr(j, lIndex) & Chr(39)
End If
If j <> rst.Fields.Count - 1 Then str2 = str2 & ", "
Next j
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "INSERT INTO MERESEK (" & str1 & " Values (" & str2 & ""
cmd.CommandType = adCmdText
cmd.Execute
str2 = ""
Next lIndex
...
***************************************************************************
It works, but it's too slow. (with 800 rec ~ 25 sec)
It worked thus far faster with a simple INSERT INTO command (bellow), but now the permissions are limited.
DoCmd.RunSQL "INSERT INTO MERESEK " & _
"SELECT MERESEK.* " & _
"FROM MERESEK IN " & Chr(34) & strAnalMDBPath & Chr(34) & _
"WHERE [MERESEK].[ID]>= " & lIDMax - Val(Forms![Main]![txtNumRecords])
What to do? Now I am in despair. ide