I have the following VB script which enters the 1st record from aa Access record set into a SQL table via a stored procedure.
The script works a treat but I want it to enter all the records from the record set. To do this I added in the 3 commands which are prefixed with ***, however when I run the code it errors stating that the stored procedure has too many arguments?
Can anyone assist me with this?
The script works a treat but I want it to enter all the records from the record set. To do this I added in the 3 commands which are prefixed with ***, however when I run the code it errors stating that the stored procedure has too many arguments?
Can anyone assist me with this?
Code:
Dim MyDb As DAO.Database
Dim cmd As New ADODB.Command
Dim tmpItem_No As Long
Set MyDb = CurrentDb
Set rsFrom = MyDb.OpenRecordset( _
"SELECT * FROM T_Sub_Sales_Transactions WHERE [Local_Tran_No] = " & Forms![F_Sales_Transactions_UP]![Local_Tran_No] & "", dbOpenSnapshot)
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = "DRIVER={SQL Server};" & "Server=123.456.789.012;DATABASE=My_DB;UID=ABCD;PWD=1234;"
.CommandType = adCmdStoredProc
.CommandText = "dbo.INS_Sub_Sales_Transaction"
***Do Until rsFrom.EOF
.Parameters.Append cmd.CreateParameter("@Tran_No", adInteger, adParamInput, 0, Me.Tran_No)
.Parameters.Append cmd.CreateParameter("@Item_No", adInteger, adParamInput, 0, rsFrom!Item_No)
.Parameters.Append cmd.CreateParameter("@Tran_Type_No", adInteger, adParamInput, 0, rsFrom!Tran_Type_No)
.Parameters.Append cmd.CreateParameter("@Entered_IP_Address", adVarChar, adParamInput, 50, rsFrom!Entered_IP_Address)
***rsFrom.MoveNext
.Execute
***Loop
End With
rsFrom.Close
Set rsFrom = Nothing
Set cmd = Nothing
Comment