ASP connection to access database instance

Source: Internet
Author: User

ASP is Microsoft's server-side dynamic scripting language. It can be used to easily connect to the access database.

To use ASP to connect to access, you need to use Microsoft's ADO component. If you are not familiar with it, you can search for it online.

The following uses an instance to demonstrate the connection process:

Set conn = server. Createobject ("ADODB. Connection") 'creates a database connection object, which is an instance of ADODB. Connection.

Connstr = "provider = Microsoft. jet. oledb.4.0; Data Source = "& server. mappath ("this is the path of the Access database,") 'Here is the connection string, provider indicates the driver, and the value of data source is the path of the access file.

Conn. connectionstring = connstr

Set rs = server. Createobject ("ADODB. recordset") 'create a database record set object

Conn. open' open the ACCESS database connection
SQL = "select * from [Table name]" 'which table of the Access database is to be operated by ASP?

Rs. Open SQL, Conn, 'ASP Open Access Database in read-only mode

<% = RS ("content") %> 'output content in the database record set
<%
Rs. movenext
Loop
Rs. Close
Conn. Close
%> 'Asp reads the ACCESS database content cyclically until the end of the record

The above is the instance connecting to the ACCESS database through ASP. Remember to destroy the created object after use. I have not destroyed it here. Do not forget to use it after connecting to the access database!



Website creation-website construction-company website-product sales website-product display website-enterprise publicity website-online shop-online mall-Information Classification Website-qq471226865

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.