(Check this out) Calling Stored Procedures from Connection object WITHOUT using Exectue method 
Author Message
 (Check this out) Calling Stored Procedures from Connection object WITHOUT using Exectue method

Did you know that you can call a Stored Procedure using the Connection 2.6
object ***without using the Connection's Execute method***?

I didn't believe it either until I tried the following sample code against
SQL Server's NorthWind database.

Just use the Stored Procedure name like one of the Connection's methods.
Pass in any input parameters. The last parameter must be a new Recordset.
e.g.
'**************
    Dim oConn As ADODB.Connection
    Dim oCmd As ADODB.Command
    Dim oRs As ADODB.Recordset

    ' Open up a ADO connection
    Set oConn = New ADODB.Connection
    With oConn
        .Open "Provider=SQLOLEDB;" & _
                "Data Source=(local);" & _
                "Initial Catalog=northwind;" & _
                "User ID=sa;Password=;"

        ' Create a new ADO Recordset instance
        Set oRs = New ADODB.Recordset

        ' Run the Stored Procedure (opens a forward-only, read-only
Recordset)
        .sp_Customers_Get "ALFKI", oRs

        ' .....

    End With
'**************

Pros:
- Fastest way to call a Stored Procedure using ADO
- Very little code (you don't have to create Command / Parameter objects)

Cons:
- No output Parameters or Return values
- Only for returning a recordset (no Insert, Update, or Delete)

--

Thanks,
Carl Prothman
Microsoft Visual Basic MVP
http://www.*-*-*.com/



Sun, 29 Jun 2003 10:04:15 GMT  
 (Check this out) Calling Stored Procedures from Connection object WITHOUT using Exectue method
Hi,

    I came across this very recently.  I would like to know how we can do
the same stuff in VC++.  Any ideas..

Regards

Zrb

Quote:
> Did you know that you can call a Stored Procedure using the Connection 2.6
> object ***without using the Connection's Execute method***?

> I didn't believe it either until I tried the following sample code against
> SQL Server's NorthWind database.

> Just use the Stored Procedure name like one of the Connection's methods.
> Pass in any input parameters. The last parameter must be a new Recordset.
> e.g.
> '**************
>     Dim oConn As ADODB.Connection
>     Dim oCmd As ADODB.Command
>     Dim oRs As ADODB.Recordset

>     ' Open up a ADO connection
>     Set oConn = New ADODB.Connection
>     With oConn
>         .Open "Provider=SQLOLEDB;" & _
>                 "Data Source=(local);" & _
>                 "Initial Catalog=northwind;" & _
>                 "User ID=sa;Password=;"

>         ' Create a new ADO Recordset instance
>         Set oRs = New ADODB.Recordset

>         ' Run the Stored Procedure (opens a forward-only, read-only
> Recordset)
>         .sp_Customers_Get "ALFKI", oRs

>         ' .....

>     End With
> '**************

> Pros:
> - Fastest way to call a Stored Procedure using ADO
> - Very little code (you don't have to create Command / Parameter objects)

> Cons:
> - No output Parameters or Return values
> - Only for returning a recordset (no Insert, Update, or Delete)

> --

> Thanks,
> Carl Prothman
> Microsoft Visual Basic MVP
> http://www.able-consulting.com/ecodegen



Tue, 01 Jul 2003 05:22:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling Stored procedure using recordset object

2. Need VB example of call DB2 stored procedure without recordset

3. Call Stored Procedures Without Command

4. Stored procedure error using ADO/ODBC connection - help?

5. HELP: Calling Stored Procedure w/large output from VB6 (using SQL Server)

6. Calling Oracle Stored Procedure from VB6 using DAO

7. Call Stored Procedure using PL/SQL

8. Calling an Oracle Stored Procedure from Vb using Q+E

9. RecordCount -1 when using a stored procedure call

10. HELP: Calling Stored Procedure w/large output from VB6 (using SQL Server)

11. Using RDO to Call Stored Procedure in SQLServer

12. Can Oracle 7 Boolean type be used as out parameter in call a stored procedure

 

 
Powered by phpBB® Forum Software