Use create procedure in access to create page 1/2 of the stored procedure

Source: Internet
Author: User
Tags odbc connection

In the help of access itself, I saw the create procedure statement. After testing for a long time, I finally found out that the create procedure statement can be used only when the oledb connection is used. ODBC connection does not support this statement, and the create table syntax error is prompted.
After creating a stored procedure, use the office access tool to open the database and view the stored procedure in "Object-query.
Syntax for creating a stored procedure: CopyCode The Code is as follows: Create procedure yourproc
(
@ Param1 varchar (254 ),
@ Param2 int
)
As
(
Select * From Table1 where ID> @ param2 and username = @ param1
)
When querying data, you only need to use:
Rs. Open "yourproc admin, 1", Conn

Myproc. vbs
Copy code The Code is as follows: Set DB = GetObject ("Script: http://www.zope.org/Members/Rimifon/DbHelper.sct ")
DB. connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source = myproc. mdb"
DB. nonquery "create table sheet1 (ID counter, name varchar (254), score INT )"
DB. nonquery "create procedure myproc (@ name varchar (254), @ score INT) as (insert into sheet1 (name, score) values (@ name, @ score ))"
DB. nonquery "create procedure result as (select * From sheet1 )"
Msgbox "created tables and stored procedures"
DB. nonquery "execute myproc rimifon, 90"
DB. nonquery "Exec myproc Fengyun, 93"
Set DS = dB. dataset ("result ")
Msgbox "executed Stored Procedures"
DB. nonquery "Drop procedure myproc"
DB. nonquery "Drop procedure result"
DB. nonquery "Drop table sheet1"
Msgbox "deleting tables and stored procedures"
Set DB = nothing
Dim result
Result = "all records:" & CHR (13)
For each item in DS
If isobject (item) then
Result = Result & item. ID & CHR (9 )&_
Item. Name & CHR (9) & CHR (9 )&_
Item. Score & CHR (13)
End if
Next
Set DS = nothing
Msgbox result

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.