Мне нужна помощь в написании следующего кода.Я написал свои комментарии, где я застрял:
Sub UploadDataUsingProc()
Call CheckFields
Call Variables.SetVariables
Call Variables.VariableValues
Dim sqlCommand As ADODB.Command
Dim TargetServer As ADODB.Connection
Set TargetServer = New ADODB.Connection
TargetServer.CommandTimeout = 99999
TargetServer.Open ( _
"driver=" & driver & ";" & _
"server=" & server & _
";database=" & databasename & ";" & _
";UID=" & username & _
";PWD=" & password & ";" & _
"Encrypt=YES;")
' Set the stored procedure
Set sqlCommand = New ADODB.Command
sqlCommand.ActiveConnection = TargetServer
sqlCommand.CommandType = adCmdStoredProc 'Set sqlCommand to be a stored procedure
sqlCommand.CommandText = "Proc_ReportMonthlySubmission"
' This is where I am not sure how do code further... Following Excel fields needs to be
' inserted into a SQL Server table using a stored procedure called "Proc_ReportMonthlySubmission"
'
' Worksheets("Keys").Range("D8").Value
' Worksheets("Keys").Range("D7").Value
' Worksheets("Keys").Range("D3").Value
' Worksheets("Keys").Range("D5").Value
'Set Procedure = "Exec " & Procedure
TargetServer.Execute (Procedure)
MsgBox "Procedure has run"