• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to execute two sql procedures using same OLE DB Connection

Mpapreja

New Member
Dear Experts,

I am using following procedure to run a sql procedure dbo.CalcItemCost.

>>> use code - tags <<<
Code:
Private Sub cmdApplyFilter_Click()
    Dim ItemCode As Variant
    Dim VariantCode As Variant
    ItemCode = Sheets("1-GetItemCost").Range("B3").Value   'Pass value from cell B3 to SellStartDate variable
    VariantCode = Sheets("1-GetItemCost").Range("B4").Value
    With ActiveWorkbook.Connections("CalcItemCostConnection").OLEDBConnection
    .CommandText = "EXEC dbo.CalcItemCost '" & ItemCode & "','" & VariantCode & "'"
     ActiveWorkbook.Connections("CalcItemCostConnection").Refresh
    End With
End Sub

The procedure is running absolutely fine and showing the results in excel sheet "1-GetItemCost" starting from Cell Ref. A7. The parameters ItemCode & VariantCode which needs to be passed to procedure dbo.CalcItemCost are specified in cells B3 & B4 Respectively.

Now, I need to run another sql procedure naming dbo.CalcItemCost_Detailed in which i wish to pass same parameters i.e. ItemCode & VariantCode to be picked from cells B3 & B4 and display the recordset starting from cell ref. A15 as shown in below image of my excel sheet.

Name:  Excel Sheet 1.jpg Views: 7 Size:  311.1 KB


Can anybody help me in executing above task? Thanks for your assistance in advance.

Mpapreja
 
Last edited by a moderator:
Back
Top