'******************************************
'*** Open Database Connection ****
'******************************************
'This sub procedure opens a connection to the database and creates a recordset object and sets database defaults
Public Sub openDatabase(strCon)
'Setup database driver and defaults
'**********************************
'SQL Server Database Defaults
If strDatabaseType = "SQLServer" Then
'Please note this application has been optimised for the SQL OLE DB Driver using another driver
'or system DSN to connect to the SQL Server database will course errors in the application and
'drastically reduce the performance!
'The SQLOLEDB driver offers the highest performance at this time for connecting to SQL Server databases from within ASP.
'MS SQL Server OLE Driver (If you change this string make sure you also change it in the msSQL_server_setup.asp file when creating the database)
strCon = "Provider=SQLOLEDB;Connection Timeout=90;" & strCon
'The GetDate() function is used in SQL Server to get dates
strDatabaseDateFunction = "GetDate()"
'Set true and false for db
strDBFalse = 0
strDBTrue = 1
'Set the lock variavbles for the db
strDBNoLock = " WITH (NOLOCK) "
strRowLock = " WITH (ROWLOCK) "
'Set the Limit opertaor for SQL Server
strDBTop1 = " TOP 1"
'MySQL Server Database Defaults
ElseIf strDatabaseType = "mySQL" Then
'This application requires the myODBC 3.51 driver
'myODBC Driver 3.51
strCon = "Driver={MySQL ODBC 3.51 Driver};Port=3306;Option=3;" & strCon
'Calculate the date web server time incase the database server is out, use international date
strDatabaseDateFunction = "'" & internationalDateTime(Now())& "'"
'Set true and false for db (true value is -1)
strDBFalse = 0
strDBTrue = -1
'Set the limit operator
strDBLimit1 = " LIMIT 1"
'MS Access Database Defaults
ElseIf strDatabaseType = "Access" Then
'Database driver (Microsoft JET OLE DB driver version 4)
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strCon
'The now() function is used in Access for dates
strDatabaseDateFunction = "Now()"
'Set true and false for db
strDBFalse = "false"
strDBTrue = "true"
'Set the limit operator for Access
strDBTop1 = " TOP 1"
End If
'Open Datbase Connection
'***********************
'Create a db connection odject
Set adoCon = CreateObject("ADODB.Connection")
Response.CharSet = "iso-8859-9"
Session.CODEPAGE = "1254"
Session.LCID = 1055
'Set error trapping
On Error Resume Next
'Set the connection string to the database
adoCon.connectionstring = strCon
'Set an active connection to the Connection object
adoCon.Open
'If an error has occurred write an error to the page
If Err.Number <> 0 Then Call errorMsg("An error has occurred while connecting to the database.", "db_connection", "common.asp")
'Disable error trapping
On Error goto 0
'Intialise the main ADO recordset object
Set rsCommon = CreateObject("ADODB.Recordset")
End Sub
ORAYA YAPIŞTIR ÇALIŞIYOR