yardımcı olanlara şimdiden teşekkürler.
database_connection.asp :
<%
'******************************************
'*** Database System Type ****
'******************************************
if request.QueryString("cikis") <> "" then
response.redirect request.QueryString("cikis")
end if
'Database Type
strDatabaseType = "SQLServer" 'Microsoft SQL Server 2000, 2005, MSDE, 2005 Express
strDatabaseType = "mySQL" 'MySQL 4.1 or MySQL 5
strDatabaseType = "Access" 'Microsoft Access Database (Flat database file, slowest and least secure of the 3)
'Dimension global variables
Dim adoCon 'Database Connection Variable Object
Dim strCon 'Holds the string to connect to the db
Dim rsCommon 'Holds the configuartion recordset
Dim strSQL 'Holds the SQL query for the database
Dim strDbPathAndName 'Holds the path and name of the database
Dim strSQLServerName 'Holds the name of the SQL Server
Dim strSQLDBUserName 'Holds the user name (for SQL Server Authentication)
Dim strSQLDBPassword 'Holds the password (for SQL Server Authentication)
Dim strSQLDBName 'Holds name of a database on the server
Dim strDatabaseDateFunction 'Holds a different date function for Access or SQL server
Dim strDatabaseType 'Holds the type of database used
Dim strDBFalse 'Holds the false value for SQL queries
Dim strDBTrue 'Holds the true value for SQL queries
Dim strDBNoLock 'Holds if the database is locked while running the query for SQL Server
Dim strRowLock 'Holds if the database row is locked while running the query for SQL Server
Dim strDBTop1 'Holds the SQL limit operator (TOP 1) for SQL Server and Access
Dim strDBLimit1 'Holds the SQL limit operator (LIMIT 1) for mySQL
'******************************************
'*** Microsoft Access ****
'******************************************
If strDatabaseType = "Access" Then
'Microsoft Access is a flat file database system, it suffers from slow performance, limited
'connections, and as a flat file it can be easly downloaded by a hacker if you do not secure
'the database file
'Virtual path to database
strDbPathAndName = Server.MapPath("db.mdb") 'This is the path of the database from the applications location
'Initilise the DB Connection String
strCon = strDbPathAndName
End If
'**********************************************************
'*** Microsoft SQL Server and MySQL Server ****
'**********************************************************
If strDatabaseType = "SQLServer" OR strDatabaseType = "mySQL" Then
'Microsoft SQL Server
'SQL Server is a high performance database server, this requires that you have installed an
'instence SQL Server 2000 or 2005 with mixed mode connection and have created a database for
'the Forum on the SQL Server
'MySQL Server
'MySQL is a free database server, it's a very fast and robust, this requires that you have
'installed an instance of mySQL 4 or higher and have created an database for the Forum
'on the mySQL database system
'Enter the details of your Microsoft SQL Server or MySQL Server and database below
strSQLServerName = "BASSBOUND\SQLEXPRESS" 'Holds the name of the SQL Server (This is the name/location or IP address of the SQL Server)
strSQLDBUserName = "sa" 'Holds the user name (for SQL Server Authentication)
strSQLDBPassword = "vwgolf" 'Holds the password (for SQL Server Authentication)
strSQLDBName = "webwizguide"
strSQLServerName = "localhost" 'Holds the name of the SQL Server (This is the name/location or IP address of the SQL Server)
strSQLDBUserName = "username" 'Holds the user name (for SQL Server Authentication)
strSQLDBPassword = "password" 'Holds the password (for SQL Server Authentication)
strSQLDBName = "senolince" 'Holds name of a database on the server
'Initilise the DB Connection String
strCon = "Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
End If
'******************************************
'*** Open Database Connection ****
'******************************************
'This sub procedure opens a connection to the database and creates a recordset object
Private 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 = Server.CreateObject("ADODB.Connection")
'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 occured write an error to the page
If Err.Number <> 0 Then Call errorMsg("An error has occured while connecting to the database.", "db_connection", "common.asp")
'Disable error trapping
On Error goto 0
'Intialise the main ADO recordset object
Set rsCommon = Server.CreateObject("ADODB.Recordset")
End Sub
'******************************************
'*** Close Database Connection ****
'******************************************
'This sub procedure will close the main recordset and close the database connection
Public Sub closeDatabase()
'Close recordset
If isObject(rsCommon) Then
Set rsCommon = Nothing
End If
'Close Database Connection
If isObject(adoCon) Then
adoCon.Close
Set adoCon = Nothing
End If
End Sub
%>
