ASP Classic database Connection file support Access,mssql server

Source: Internet
Author: User
Tags mssql mssql server

ASP Classic database connection file support Access,mssql server
Dim conn,connstring
Sub openconn ()
 if db_type = "Access" Then
  connstring = "Provider = Microsoft.jet.oledb.4.0;data Source =" & Server.MapPath (Accpath)
 els EIf Db_type = "SQL" Then
  connstring = "Provider = SQLOLEDB; User ID = "& Sqlusername &"; Password = "& SQLPassword &"; Initial Catalog = "& Sqldatabasename &"; Data Source = "& Sqlsource &";
 else
  response.write The system database type is incorrect, check that the database type in the inc/const.asp is set correctly. "
  response.end
 end If
  ' on Error Resume Next
 set Conn = Server.CreateObject ( connobj)
 conn.open connstring
 if Err Then
  err.clear
  conn.close: Set Conn = Nothing
  response.write system database connection error, please check that the database connection section in Inc/const.asp is set correctly. '
  response.end
 end If
End Sub

Sub closeconn ()
 on Error Resume Next
 if isobject (Conn) Then
  conn.close:set Conn = Nothing
 end If
End Sub

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.