CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Posts
    26

    Running Stored Procedure

    Hello

    I want to know how can I run a sql server stored procedure from my program written in VB

    Thannks
    Ehsan


  2. #2
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329

    Re: Running Stored Procedure


    Dim cnn as ADODB.Connection
    Dim rst as ADODB.Recordset
    set cnn = new ADODB.Connection
    set rst = new ADODB.Recordset
    cnn.ConnectionString = "Your Connection string"
    cnn.Open
    'for a stored procedure which doesn't return any records
    cnn.Execute "sp_MyStoredProcedure 'Param1',2"
    'to return records use either:
    set rst = cnn.Execute ("sp_MyStoredProcedure 'Param1',2)
    'Or
    rst.Open "Execute sp_MyStoredProcedure 'Param1',2",cnn,adOpenStatic,adLockOptimistic
    rst.Close
    set rst = nothing
    cnn.Close
    set cnn = nothing




    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured