Access编程交流网
  • 设为首页|收藏本站|繁体中文|手机版
  •     
  • Access培训-Access开发平台-Access行业开发

  • 首页
  • 资讯
  • 技巧
  • 源码
  • 行业
  • 资源
  • 活动
  • 关于

技巧

ACCESS数据库

启动/设置/选项/背景

修复/压缩

安全/加密/解密

快捷键

版本升级/其它等

数据表

命名方式/设计规范

表设计

查询

Sql语言基础

选择查询

更新查询

删除查询

追加查询

生成表查询

交叉表查询

SQL特定查询

查询参数

查询综合应用

界面/窗体/控件

标签

文本框

命令按钮

组合框/列表框

选项组/复选框/选项按钮

选项卡

子窗体

窗体本身/综合应用

其它

报表打印

报表设计

高级报表

模块/函数/VBA/API/系统

VBA基础

内置函数

调试/跟踪/Debug

模块/类模块

API/COM/系统相关

字符数字日期

网络通信游戏

加密解密安全

文件处理

经典算法

宏/菜单/工具栏/功能区

宏/脚本

菜单/工具栏

功能区/Ribbon

图表/图形/图像/多媒体

图表

图形/图像

音频

视频/动画

DAO/链接表/ADO/ADP

DAO/链接表/ODBC

ADO/RDO

ADP

ActiveX/第三方控件/插件

Treeview树控件

ListView列表控件

Toolbar工具栏控件

微软其它控件

Dbi-Tech

CodeJock

Grid++Report

FastReport

ComponentOne

加载项/插件/Addin

OFFICE集成/导入导出/交互

Excel导入导出/交互

Word导入导出/交互

PPT交互

Outlook控制/邮件

Text文本文件/INI/CSV

PDF/SWF/XML格式

CAD格式

Sharepoint/其它Office

SqlServer/其它数据库

表

视图

存储过程/触发器

函数

用户/权限/安全

调试/维护

SqlServer其它/综合

发布/打包/文档/帮助

开发版/运行时

打包/发布/部署

开发文档/帮助制作

Access完整行业系统

采购管理系统

销售管理系统

仓库管理系统

人力资源管理HRM

CRM管理系统

MRP/ERP管理系统

BRP/流程优化

其它管理系统

心得/经验/绝招
其它/杂项
Excel技巧

Excel应用与操作

Excel开发编程

Word技巧

Word应用与操作

Word开发编程

Outlook技巧

Outlook应用与操作

Outlook开发编程

热门文章

  • Access常用Sql语句..
  • 利用IIF、Switch函..
  • 使用SQL语句创建表且设置..
  • 新手来看:ACCESS中是..
  • 一道褒贬不一的 SQL 考..
  • SQL必知必会(6)排序数..

最新文章

  • 使用SQL语句创建表且设置..
  • 利用IIF、Switch函..
  • sql模糊查询的几种常见方..
  • 获取本月、上月、下月天数的..
  • Access常用Sql语句..
  • sql语句中like通配符..

联系方式

Access交流网(免费Access交流)

QQ:18449932 

网  址:www.access-cn.com

当前位置:首页 > 技巧 > 查询 > Sql语言基础
Sql语言基础

如何用jet sql语句创建存储过程(查询)

原文来自微软KB

currentproject.connction.execute "create procedure name1 (vde varchar) as select * from msysobjects"

--------------------------------
Create a Parameterized Jet Stored Procedure using DDL in access 2000
The information in this article applies to:
Microsoft access 2000
Microsoft Visual Basic for Applications

This article was previously published under Q202116 
Advanced: Requires expert coding, interoperability, and multiuser skills. 


IN THIS TASK
SUMMARY

Creating a Stored Procedure
SUMMARY
This article shows you how to create a stored procedure in the Visual Basic Environment and, if needed, how to add a parameter to the existing stored procedure. 

NOTE: Native stored procedures are new in Microsoft access 2000. You cannot create and run stored procedures through the user interface. You must use the Visual Basic Environment with ActiveX Data Objects (ADO) or the Database Definition Language (DDL).

back to the top 
Creating a Stored Procedure
The following steps show you how to create a stored procedure with a parameter and how to run it in the Visual Basic Environment: 
In the sample database Northwind.mdb, create a new module called TestStoredProc. 
On the Tools menu, click References. In the list of available references, click to select (check) Microsoft ActiveX Data Objects 2.1 Library. 
Type the following in the new module:
Public Function CreateProc()

   Dim strProc As String

   strProc = "Create Procedure qryCustByCity " & _
             "(prmCity varchar) as " & _
             "select * from Customers where City = prmCity"

   CurrentProject.Connection.Execute strProc

End Function
                    
In the Immediate window, type the following and press ENTER:
?CreateProc
                    
Steps 1 though 4 create a stored procedure called strProc, which queries for records whose city matches the parameter, prmCity. The remaining steps involve creating code that runs strProc and passes a parameter. 


Return to the module that you created in step 1. 
Type the following code:
Public Function RSFromParameterQuery(strCity As String)

   Dim prm As ADODB.Parameter
   Dim cmd As ADODB.Command
   Dim rst As ADODB.Recordset

   Set cmd = New ADODB.Command
   Set cmd.ActiveConnection = CurrentProject.Connection

   cmd.CommandText = "qryCustByCity"
   cmd.CommandType = adCmdStoredProc

   Set prm = cmd.CreateParameter("prmCity", adVarChar, _
             adParamInput, Len(strCity))

   prm.Value = strCity

   cmd.Parameters.Append prm

   Set rst = New ADODB.Recordset
   rst.Open cmd

   Do Until rst.EOF
      Debug.Print rst(0), rst(1), rst(2)
      rst.MoveNext
   Loop

End Function
                    
In the Immediate window, type the following and press ENTER:
?RSFromParameterQuery("London")
                    
In the Immediate window, you should see a listing of the customers in London. 

back to the top 
Last Reviewed: 10/27/2002 
Keywords: kbhowto kbHOWTOmaster kbProgramming KB202116 kbAudDeveloper 

发布人:ec-ACCESS911  
分享到:
点击次数:  更新时间:2003-12-06 20:37:51  【打印此页】  【关闭】
上一条:能否写一种在数据库窗口查询标签里面看不见的查询?(view/Proced  下一条:如何用sql语句删除表关系?



相关文章

  • • 使用SQL语句创建表且设置自动编号字段
  • • 利用IIF、Switch函数创建自定义排序次序
  • • sql模糊查询的几种常见方法
  • • 获取本月、上月、下月天数的函数
  • • Access常用Sql语句大全
  • • sql语句中like通配符的汇总(*?!#-等含义)
  • • SQL查询语句的一般格式小结
  • • 报表中先按组再按条件统计

热门文章

  • [2003-12-06] 新手来看:ACCESS中是否存在存储过程?access数据库
  • [2007-01-12] Sql Server 和 Access 操作数据库结构的常用Sqlaccess数据库
  • [2003-12-21] ACCESS中使用SQL语句应注意的地方及几点技巧access数据库
  • [2003-12-06] 如何查询与指定日期同属一周内的数据?access数据库
  • [2009-11-11] 测试查询速度access数据库
  • [2003-12-06] sql如何返回第三或从第三条记录开始返回(分页问题)?access数据库

热门产品

公司动态|在线留言|在线反馈|友情链接|会员中心|站内搜索|网站地图

中山市天鸣科技发展有限公司 版权所有 1999-2023 粤ICP备10043721号

QQ:18449932

Access应用 Access培训 Access开发 Access平台

access|数据库|access下载|access教程|access视频|access软件

Powered by MetInfo 5.3.12 ©2008-2025  www.metinfo.cn