MSSQL DB Connection

Connects to MSSQL database from Classic ASP
All DB variables need to be already defined
DBServer, DBName, DBUser, DBPass
Content below is used to be in Inc_Conn.asp file and included inside tool ASP files

CodeFunctionName
What is this?

Public

Tested

Original Work
<%
Server.ScriptTimeout = 200
' Variables needed to be set
' DBServer = "db.server.com"
' DBName = "DatabaseName"
' DBUser = "dbadmin"
' DBPassword = "pwdofdbuser"
Err.Clear
On Error Resume Next
Set Connection = Server.CreateObject("ADODB.Connection")
ConnString = "PROVIDER=SQLNCLI11 ;SERVER=" & DBServer & ";DATABASE=" & DBName & ";USER ID=" & DBUser & ";PASSWORD=" & DBPassword & ";"
' ConnString = "PROVIDER={SQL Server} ;DATA SOURCE=" & DBServer & ";DATABASE=" & DBName & ";USER ID=" & DBUser & ";PASSWORD=" & DBPassword & ";"
Connection.Open ConnString
If Err.Number < > 0 Then Response.Redirect "/Error"
On Error GoTo 0

% >

Views 4,489

Downloads 1,281

CodeID
DB ID