Several ways to connect MSSQL in ASP!

Source: Internet
Author: User
Tags connect mssql

Method One:

<%
Dim conn
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Provider=sqloledb;data source=db.janusgroup.cn; uid=web286418; PWD=J2Z0H1V2;DATABASE=WWW_JANUSGROUP_CN "
Set conn = Server.CreateObject ("ADODB. Connection ")
dsntemp= "Driver={sql Server}; server=db.janusgroup.cn; uid=web286418; PWD=J2Z0H1V2;DATABASE=WWW_JANUSGROUP_CN "
Conn.Open Dsntemp
%>

Method Two:

<%
Option Explicit
Dim startime
Dim conn
Dim connstr
Dim Db,pass_word,user_id,data_source
Startime=timer ()
db= "WWW_DB_CN" database name
pass_word= "0h1v2" ' password= account password
User_id= "Web2-sql8" ' User id= login account
Data_source= "100.100.100.100" ' Data source= service name or IP

Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=SQLOLEDB.1; Password= ' "&pass_word&"; Persist Security info=true; User id= ' &User_ID& '; Initial catalog= ' &db& ' ';D ata source= ' &Data_Source& ' '
Conn. Open ConnStr
function Closedb
Conn.close
Set conn = Nothing
End Function
%>



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.