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.