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