6 SQL Server is a server-level database, the use of more stringent requirements, you must enter a username and password to use.
Function createsqlserverrecordset (computer name, user ID, user password, database name data table or view table or select instruction)
Dim Params, Conn
Set creatsqlserverconnection = Nothing
Set conn = Server.CreateObject ("ADODB. Connection ")
Params = "Provider=SQLOLEDB.1"
Params = Params & ";D ata source=" & Computer
Params = Params & "; User id= "& UserID
Params = Params & "; Password= "& Password
Params = Params & ". Initial catalog= "& database name
Conn Open Paras
Set Createsqlserverrecordset = Server.CreateObject ("ADODB. Recordset ")
Createsqlserverrecordset.open Source, Conn, 2, 2
End Function
Using the above function can open a common type of database, and then use ADO Recordset object to add records, delete records, modify records and other functions can operate on the database. But to illustrate, in the actual development we found that, if the use of DBF, DBC, Excel database, the efficiency of the implementation of the MDB database is not efficient, it is best to use the MDB type database as much as possible.
If you use DBF, DBC, Excel database, the following points to note: Excel database can only read, add records, modify records, but not delete records; DBF, dbc< can read records, add records, delete records, modify records, but when adding records, None of the field values can be empty, which shows that the limitations are great, so use an MDB or SQL database as much as possible.
Iv. examples (accessing Excel data Tables)
To further illustrate the use of these functions, this article gives an example of accessing Excel data tables, and other functions are accessed in a similar way. Suppose you have an Excel file named 1.xls in Figure 2, which contains three worksheets, one, two, and three. Below you need to use the above function to access the worksheet "class" data.
Write an ASP file (file name 1.asp) to access this Excel file.
Here is the ASP source code:
<%
' Create a Connection object
Function Createexcelrecordset (Xlsfile,sheet)
Dim Rs,conn,driver,dbpath
Set conn = Server.CreateObject ("ADODB. Connection ")
Driver = "Driver={microsoft Excel Driver (*.xls)};"
DBPath = "dbq=" & Server.MapPath ("Xlsfile")
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.