• 14-08-2010, 12:32:40
    #1
    merhabalar, webwiz forumum vardı siteyi gecen gün access veritabanından mysql e yükselttim ama veritabanı bağlantısını yapamadım. /database/database_connection.asp buradaki veritabanı balantısını değiştiremedim.

    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
    %>
  • 14-08-2010, 13:18:06
    #2
    Üyeliği durduruldu
    Set MySQL_Baglanti = Server.CreateObject("ADODB.connection")
    Veritabani = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; UID=root; pwd=; db=asp;"
    MySQL_Baglanti.Open Veritabani

    yukarıdaki bağlantıda MySQL ODBC 3.51 Driver sürümü için yapıldı bunu senin kendi MySQL ODBC sürümün için ayarlaman lazım tabi sadece bununla da bitmiyor maalesef access ten mysql e geçiş esnasında bazı asp kodların çalışmayacaktır. bunlar recordcout, move(5), addnew gibi bunların yerine
    örn: recordcount yerine sqlkod içine count kullanman lazım
    move(5) gibi komutlarınıda yine sql kodunun içinde limit i kullanman gerek
    ve addnew komutunun yerine kayıtları insert into ile yapman lazım bunun gibi değişiklikler yapman gerek kodlarında şimdilik aklımda var olan bunlar daha fazlasını bilen arkadaş varsa yazarlar zaten yada sen dönüştürmeye başla hata aldıkça yaz elimizden geldiğince cevap veririz.
  • 14-08-2010, 13:41:24
    #3
    merhaba script tamamen mysql e uyumludur. script tüm veritabanı dilleri ile uyumludur. verdiğiniz kodu üsteki sayfaya uyarlarsanız daha anlaşılır olur. teşekkürler şimdiden.
  • 14-08-2010, 21:47:44
    #4
    hala yardım beklemekteyim yardım eden olursa sevinirim..
  • 15-08-2010, 04:34:09
    #5
    Üyeliği durduruldu
    Kodlar arasındaki

    '*** Microsoft SQL Server and MySQL Server ****

    kısmının altını değiştirmen gerekiyor.


    strSQLServerName = "localhost" -- Bunu değiştirme.
    strSQLDBUserName = "username" -- Veritabanını oluşturduktan sonra, sana sorduğu kullanıcı adı ve şifre bölümündeki Kullanıcı Adı nı yazacaksın.
    strSQLDBPassword = "password" -- Yukarıda belirttiğim gibi burayada şifreyi
    strSQLDBName = "senolince" -- ve burayada veritabanı adını.

    Daha önce kullanmadığım için bilmiyorum fakat, Bir üstte de bu değişkenlerin aynısını vermiş. Eğer bu bilgileri doğru girdiğin halde çalışmazsa,

        '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
    her 2 kısımdaki bilgileri aynı girip dene. Olmadı üsttekini silip dene

    Kolay gelsin..
  • 15-08-2010, 19:20:13
    #6
    üstteki access db kısmını silince hata alıyorum, aşağıdaki bilgileri girdim fakat yinede access e bağlanıyor forum yani erileri access den cekiyo.
  • 15-08-2010, 19:57:19
    #7
    Kimlik doğrulama veya yönetimden onay bekliyor.
    kullanılmayacak olan db türünü önüne tırnak koyarak kapatmalısın.

    'strDatabaseType = "SQLServer"
    strDatabaseType = "mySQL"
    'strDatabaseType = "Access"
  • 15-08-2010, 21:43:10
    #8
    denom adlı üyeden alıntı: mesajı görüntüle
    kullanılmayacak olan db türünü önüne tırnak koyarak kapatmalısın.

    'strDatabaseType = "SQLServer"
    strDatabaseType = "mySQL"
    'strDatabaseType = "Access"
    merhaba bilgileri dedğiniz şwkilde değiştirdim ama söyle bir hata aldım:

    Server Error in Forum Application
    An error has occured while reading user data from the database.
    Please contact the forum administrator.
    
    Support Error Code:- err_mySQL_getUserData()_get_member_data
    File Name:- functions_login.asp
    
    Error details:-
    Microsoft OLE DB Provider for ODBC Drivers
    [MySQL][ODBC 3.51 Driver][mysqld-5.0.91-log]Table 'senolince.tblAuthor' doesn't exist
  • 15-08-2010, 22:10:24
    #9
    'senolince.tblAuthor' adında bir tablo bulamıyor database de.
    Sanırım database sıfır değil yoksa bu isimde bir tablo aramazdı.
    Kontrol panel çalışıyorsa bu isimde bir yazar açmalısın veya mevcut olanı kaldırıp yeniden oluşturmalısın.