search
HomeDatabaseMysql Tutorial 在Access中使用“存储过程”

在Access中使用“存储过程”

Jun 07, 2016 pm 04:02 PM
accessaspusestored procedureuspass

我们已经熟悉在 ASP 中通过调用 SQL Server 存储过程来执行数据库操作 不过大家是否知道 在桌面级数据库 Access 中 我们也能够创建并使用 存储过程 ? Access + ASP 是开发轻量级 Web 应用程序的绝佳组合 简单 快速 兼容性好 但是性能通常不高 并且 用 ADODB

  我们已经熟悉在 ASP 中通过调用 SQL Server 存储过程来执行数据库操作不过大家是否知道在桌面级数据库 Access 中我们也能够创建并使用存储过程
Access + ASP 是开发轻量级 Web 应用程序的绝佳组合简单快速兼容性好但是性能通常不高并且用 ADODBConnection 和 Recordset 对象来执行 SQL 语句的方式也有一些不方便因为带参数的 SQL 语句的参数值也常常是拼接到字符串中于是便有了诸如单引号问题这样的麻烦使用存储过程的一个好处就是支持 SQL 语句参数值的另外提供

  事实上Access( 及以上版本)中所谓存储过程和 SQL Server 中的 Stored Procedure 是不能比的它只能算是Stored Procedure Lite不支持多条 SQL 语句不支持逻辑语句(呵呵毕竟不是 TSQL)等等我也还不清楚它是不是预编译了不过正如同 VBScript 实现的所谓仅仅具有封装性对于代码结构的美化和程序重用性具有很大促进一样Access 的轻量存储过程对于规范小出错几率的数据库操作应该也有帮助并且性能可能会有提高

  下面我译 step by step 的方式介绍如何在 Access 中创建存储过程然后在 ASP 程序中使用它

  (一)在 Access 中创建存储过程

  不知道大家的 Access 应用水平如何反正它对于我来说仅仅就是一个 MDB 数据库文件的创建工具我只会新建 MDB 文件然后在 Access 的界面中创建表索引约束等等over~

  Access 中的查询就扮演了存储过程的角色下文中我提到的 Access 的存储过程或者查询都是指这个东西

  对于查询的创建Access 提供了一个傻瓜工具类似 VSNET 里边建立 DataAdapter 时的向导不过我喜欢直接写 SQL 代码

  好下面先看看我们这个简单的例子中所使用的数据库的表结构

  
在Access中使用“存储过程”

  然后在 Access 主界面上点击左侧的查询按钮再在右边双击在设计视图中创建查询以打开查询设计视图

  
在Access中使用“存储过程”

  这时弹出的是可视化的查询生成器我们首先添加 SQL 语句需要涉及的表

  
在Access中使用“存储过程”

  添加表之后在设计视图上点击鼠标右键选择SQL 视图以切换到 SQL 代码编辑窗口

  
在Access中使用“存储过程”

  好下面说说 Access 的存储过程的特点

  Access 的查询我目前的感觉是对 SQL 语句的一个包装或许进行了某种优化如预编译我们不能像写 SQL Server 存储过程那样使用多重操作事务逻辑判断循环等等……

  

  本新闻共当前在第页        

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are stored procedures in MySQL?What are stored procedures in MySQL?May 01, 2025 am 12:27 AM

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

How does query caching work in MySQL?How does query caching work in MySQL?May 01, 2025 am 12:26 AM

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

What are the advantages of using MySQL over other relational databases?What are the advantages of using MySQL over other relational databases?May 01, 2025 am 12:18 AM

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment