A complete ASP database connection program

Source: Internet
Author: User
Tags access database

About the ASP tutorial database tutorial connectors Such open questions, is generally just learning the ASP program soon friends, is also said that the introduction of ASP's friends to learn, in the ASP and Access database to connect the words need to use the provider= Microsoft.Jet.OLEDB.4.0 to do, look at the example below.

<% @language = "VBScript" codepage= "936"%>
<%
Dim db
Const Databasetype= "Access" & nbsp;   
db= "bbs/www.111cn.net/cnhww.asp"       //Setting the Connection database path     
         On Error Resume Next
 dim CONNSTR
 dim conn
  connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (db)
  set conn = Server.CreateObject ("adodb.connection")
 conn.open connstr// Open the database connection
 if err then
  err.clear
  set conn = Nothing
   Response.Write Database connection error, please check the database parameter settings in the Conn.asp file. "
  response.end
 end if
Sub Closeconn ()//Close database connection
 on Error Resume Next
 if IsObject (conn) then
  conn.close
  set conn=nothing
 end if
End Sub
%>< /p>

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.