Tools Links Login

Undocumented Trick for calling stored procedures in vb using ADO

Undocumented Trick for calling stored procedures in vb using ADO

Original Author: Sheraze S

There is an undocumented Trick for calling stored procedures in vb using ado

There is an undocumented shortcut for calling stored procedures in vb using ado.

We normally call stored Procedures using the following

1)command object.

2)recordset object's open method.

3)connection object's execute method.

Here are a Few Examples of the undocumented way to call stored procedures using vb and ado:

1)a simple example without input parameters or return recordsets.

Stored Procedure:

Create proc p1

as

select * into copy1 from authors

VB Call

Dim cn As New ADODB.Connection

Dim rs As New ADODB.Recordset

cn.Open "driver=sql server;server=sherazesheraze;"

cn.p1

'u wont get all the stored procedure names at design time.

2)this sample takes an input parameter and returns a recordset

Stored Procedure:

Create proc p2 (@name varchar(10))

as

select * from authors where au_lname = @name

VB Call

Dim cn As New ADODB.Connection

Dim rs As New ADODB.Recordset

cn.Open "driver=sql server;server=sherazesheraze;database=pubs"

cn.p2 "white", rs

'u wont get all the stored procedure names at design time.

-sheraze

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 82 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.