ASP Programming Excel (improved edition)

Source: Internet
Author: User
Tags access database
Abstract This article mainly introduces how to use Excel as a database and use ASP Programming to operate it.
Keywords ASP, Excel, programming, database
I. Question proposal
I encountered many big and small problems in ASP Programming. I encountered such a problem when I designed a website for a bookstore. At first, Access was used as a database. This database is mainly used to store the information of books in the bookstore. However, when there are too many entries in the database, the size of the database will become very large. In actual applications, the website space is limited. Many customers who want to build websites do not have their own hosts. The website space is purchased from the website space provider, this requires that the size of files on the website be reduced as much as possible under certain conditions of the website space. So I chose Excel as the database.
II. Methods and instructions
Regard the excelfile (such as book.xls) as a database, and each worksheet (sheet) as a database table. Suppose the name of the first row in Excel, so the scope you define must include the content of the first row.
The row title (field name) in Excel cannot contain numbers. An error occurs when the Excel driver encounters this problem (for example, your row title is "F1 "). If a column in your Excel file contains both text and numbers, the ODBC driver of Excel cannot process the data in this row, you must ensure that the data type of this column is consistent.
When using Excel as a database, you can use Microsoft Excel to edit data on a local machine. When creating books and data, booksellers often download the required books from major publishers. These books and information are in a fixed format, the bookseller adds the downloaded data to the Excel database in large batches by copying, pasting, and other methods. After completing the data, upload the Excel database to the website. This method has the following advantages: fast, convenient, and easy to operate.
The first step to access database information is to establish a connection with the database source.
How to connect to an Excel database:
<%
Dim Conn, Driver, DBPath, Rs
Set Conn = Server. CreateObject ("ADODB. Connection ")
Driver = "Driver = {Microsoft Excel Driver (*. xls )};"
DBPath = "DBQ =" & Server. MapPath ("book. mdb ")
Conn. Open Driver & DBPath
%>
Where Driver = "Driver = {Microsoft Excel Driver (*. xls )};"
This line of code is critical, mainly for driver selection. We can compare it with the database connection method using Access.
<%
Dim Conn, Driver, DBPath, Rs
Set Conn = Server. CreateObject ("ADODB. Connection ")
Driver = "Driver = {Microsoft Access Driver (*. mdb )};"
DBPath = "DBQ =" & Server. MapPath ("book. mdb ")
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.