Stored Procedures for database operations using vb

Source: Internet
Author: User

The stored procedure is as follows:
Create proc sp_recordset
@ Bbb int
As
Select * from aaa where bbb = @ bbb
The vb Code is as follows:

Dim cmd As ADODB. Command
Dim conn As ADODB. Connection
Dim rs As ADODB. Recordset
Dim ADOPrm
Set ADOPrm = New ADODB. Parameter


Set rs = New ADODB. Recordset
Set conn = New ADODB. Connection
Conn. ConnectionString = "Provider = SQLOLEDB.1; Persist Security Info = False; User ID = sa; Initial Catalog = DB_PurchaseOrder; Data Source = ."
Conn. Open

Set cmd = New ADODB. Command
Cmd. CommandType = adCmdStoredProc
Cmd. ActiveConnection = conn
Cmd. CommandText = "sp_recordset"
Set ADOPrm = cmd. CreateParameter ("@ bbb", adInteger, adParamInput)
Cmd. Parameters. Append ADOPrm
Cmd. Parameters ("@ bbb"). Value = "123"

Set rs = cmd. Execute ()

MsgBox rs (0) & rs (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.