ASP database: ASP connection access and SQL Server database code

Source: Internet
Author: User
Tags microsoft sql server management studio

1. asp connection to access databaseCodeSave as a conn. asp file. Because each page uses this file, it is made into a separate file for other files to call.
<%
Set rs = server. Createobject ("ADODB. recordset ")
DB = "db1.mdb"
Set conn = server. Createobject ("ADODB. Connection ")
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath (db)
Conn. Open connstr
%>
In this way, when other files need to call this file method: <! -- # Include file = "conn. asp" -->. You do not need to set the Rs.

 

2. asp connection to SQL Server database

<%
Set conn = server. Createobject ("ADODB. Connection ")
Set rs = server. Createobject ("ADODB. recordset ")
Connstr = "provider = sqloledb.1; server = pc2009101911vit; database = yunzheng; user id = sa; Password = fengyafei ;"
Conn. Open connstr

%>

the server value here is your computer name or remote IP address. To view the local computer name, run the systeminfo command and view the "host name "; the database value is the name of the database you created. the user ID value is the name entered when you installed the SQL Server database. The default value is Sa; the password value is the password you entered when installing the SQL Server database. The user name can be seen in "Object Resource Manager"-"pc2009101911vit (local computer name)"-"security" in Microsoft SQL Server Management studio.

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.