Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this code below to Execute a Command in Stored Procedure in SQL
Server. My problem is that I keep having an error message saying Error: Operation is not allowed when the object is closed. 3704 I have no idea what that means, Option Explicit Dim cnnDW As ADODB.Connection Dim rsDW As ADODB.Recordset 'Dim cnnSP As ADODB.Command Dim sQRY As String Dim strDWFilePath As String Sub GetData() On Error GoTo Err: strDWFilePath = "Driver={SQL Native Client};Server=CISSQL1;Database=CORPINFO;Trusted_C onnection=Yes" Set cnnDW = New ADODB.Connection Application.ScreenUpdating = False cnnDW.Open strDWFilePath Sheet1.Range("E4:F9").ClearContents Set rsDW = New ADODB.Recordset sQRY = "DECLARE @wlvals varchar(100) " & _ "SET @wlvals = char(39) + 'T2DEA' + char(39) + ',' + char(39) + 'T2DEP' + char(39) " & _ "EXEC sp_WLName_Report 'September', '2008', '18-09-2008', @wlvals" rsDW.CursorLocation = adUseClient rsDW.Open sQRY, cnnDW, adOpenDynamic, adLockOptimistic, adCmdText Application.ScreenUpdating = False Sheet1.Range("E4").CopyFromRecordset rsDW rsDW.Close Set rsDW = Nothing MsgBox "Import Complete", vbInformation, "SQL Connection" cnnDW.Close Set cnnDW = Nothing Exit Sub Err: MsgBox "The following error has occured-" & vbCrLf & vbCrLf & VBA.Error, vbCritical, "SQL Connection" MsgBox VBA.Err End Sub Where am I going wrong? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Return a stored procedure value to Excel | Excel Programming | |||
Run SQL Server stored procedure in Excel macro | Excel Programming | |||
execute stored procedure from excel | Excel Worksheet Functions | |||
Getting stored procedure result to excel | Excel Programming | |||
Run a stored procedure in Excel 2K | Excel Programming |