Port Access to SQL Server

Source: Internet
Author: User

Access developers from SQL Server are faced with many difficulties. However, the most difficult problem is the handling of dynamic SQL. In Access, it is quite common to specify the row of the control as a string. For example, the form contains many selectors (SalesGroup, State/Province/Canton, Beginning Date, and Ending Date). Access developers generally check these controls to see which ones are Null, then write SQL statements to delete these Null values.

Connecting to SQL Server in this way has the following Disadvantages:

All processing is completed on the client, rather than on the server.

The code for parsing these controls and processing SQLq statements is lengthy.

This method can easily cause injection attacks ).

Access developers eager to expand to SQL Server must solve two problems:

1. Identify all records and row data sources that are not based on name queries.

2. Use name query to replace all queries.

For dynamic query processing, you can use the following code:

SELECT *

FROM SomeTables

WHERE ColumnOfInterest = Forms ("myForm"). ControlOfInterest

AND Column2OfInterest = Forms ("myForm"). Control2OfInterest

For simplicity, we assume that the Access form contains only two controls. The Access method parses the control value in the code, and then processes each dynamic SQL query using a non-zero value.

This is a method without a wizard. What you need is a storage program that is parameterized to receive all data from controls on the form. For example, if the given two controls are triggered by the stored program's own data, if the value is Null, the stored program will be intelligently executed.

Here is a simple technique for implementing this process:

SELECT *

FROM SomeTables

WHERE ColumnOfInterest = 12345 OR ColumnOfInterest is NULL

Related Article

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.