Optimizing ASP Program Performance (turn) (ii)

Source: Internet
Author: User
Database access

Accessing the database will slow down the program quickly, but there are no databases and many sites are not. Do not use the embedded SQL statements to access the database, you can use stored procedures to access the database, which will win a lot of program performance, but also very flexible. By using stored procedures and with ActiveX Data Objects (ADO), you can control how the stored procedures are exported to the maximum extent possible.
Verify that the database is indexed because it directly affects the overall performance of the application. At the same time, pay attention to running the UPDATE STATISTICS program on the database to better track the data distribution. Note that some databases, such as Ms Access, are not suitable for enterprise applications, and SQL Server 7.0 or Oracle is better suited to do this.
Let SQL do the design work, including computing, adding, sorting, and grouping data. Do not write these features in other languages, you can write a query to complete.
Any field you want to evaluate is the simple syntax shown below:
SELECT Count (*) from Publishers WHERE state= ' NY '
If you want to calculate a special field, you must group by that field, otherwise, you will not work:
SELECT count (city), publishers GROUP by city
Then determine the sorting method:
SELECT * FROM tablename WHERE FieldName >50 OR fieldname< to by FieldName2, FieldName3
You still use an ODBC system or file DSN to connect to the database, or you can connect using a quick OLE DB technology. Using the latter, when you move a Web file, you no longer need to modify the configuration.
OLE DB is located between the application and the ODBC layer. In an ASP page, ADO is a program located on top of OLE DB. When ADO is invoked, it is first sent to OLE DB, which is then sent to the ODBC layer. You can connect directly to the OLE DB layer, and when you do this, you will improve server-side performance. How do you connect directly to OLE DB?
If you use SQL Server 7, use the following code as the connection string:
strconnstring = "dsn= ';D river={sql SERVER};" & _
"UID=MYUID; Pwd=mypwd; "& _
"DATABASE=MYDB; Server=myserver; "
The most important parameter is the "driver=" section. If you want to bypass ODBC and use OLE DB to access SQL Server, use the following syntax:
strconnstring = "Provider=SQLOLEDB.1; Password=mypassword; "& _
"Persist security info=true; User Id=myuid; "& _

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.