change from access db to mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webandwe
    New Member
    • Oct 2006
    • 142

    change from access db to mysql

    Hi,

    Can somebody please show me how to change the connection so I can make it work with my MYSQL database... I just need this login to work then I'm done wiht my project. I don't know what is going on here and is, this far from throughing my laptop into the wall.....

    I want to change

    cStr = "DRIVER={Micros oft Access Driver (*.mdb)};"
    cStr = cStr & "DBQ=" & Server.MapPath( "\path\to\datab ase.mdb") & ";"
    Conn.Open(cStr)

    so it can work of from my MySQL database. my current dns

    Connection.Open "DSN=mysql_ dsn"

    Code:
    <%
    Response.Expires = -1000 'Makes the browser not cache this page
    Response.Buffer = True 'Buffers the content so our Response.Redirect will work
    
    Dim Error_Msg
    
    login = Request.Form("login")
    If login = "logout" Then
        Session("UserLoggedIn") = ""
        ShowLogin
    Else
        If Session("UserLoggedIn") = "true" Then
            AlreadyLoggedIn
        Else 
            If login = "true" Then
                CheckLogin
            Else
                ShowLogin
            End If
        End If
    End If
    
    Sub ShowLogin
    Response.Write(Error_Msg & "<br>")
    %>
    <form name=form1 action=login.asp method=post>
    User Name : <input type=text name=username><br>
    Password : <input type=password name=userpwd><br>
    <input type=hidden name=login value=true>
    <input type=submit value="Login">
    </form>
    >%
    End Sub
    
    Sub AlreadyLoggedIn
    %>
    You are already logged in.
    Do you want to logout or login as a different user?
    <form name=form2 action=login.asp method=post>
    <input type=submit name=button1 value="Yes">
    <input type=hidden name=login value="logout">
    </form>
    %>
    End Sub
    
    Sub CheckLogin
    Dim Conn, cStr, sql, RS, username, userpwd
    username = Request.Form("username")
    userpwd = Request.Form("userpwd")
    Set Conn = Server.CreateObject("ADODB.Connection")
    cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
    cStr = cStr & "DBQ=" & Server.MapPath("\path\to\database.mdb") & ";"
    Conn.Open(cStr)
    sql = "select a from admin where a = '" & LCase(username) & "'"
    sql = sql & " and b = '" & LCase(userpwd) & "'"
    Set RS = Conn.Execute(sql)
    If RS.BOF And RS.EOF Then
        Error_Msg = "Login Failed. Try Again."
        ShowLogin
    Else
        Session("UserLoggedIn") = "true"
        Response.Redirect "pages.asp"
    End If
    End Sub
    %>
    Last edited by DrBunchman; Sep 15 '08, 01:17 PM. Reason: Added [Code] Tags - Please use the '#' button
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    mySQL conn strings

    Try this. If you make changes and still cannot resolve your connection let me know.

    Comment

    Working...