By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

change from access db to mysql

100+
P: 142
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={Microsoft Access Driver (*.mdb)};"
cStr = cStr & "DBQ=" & Server.MapPath("\path\to\database.mdb") & ";"
Conn.Open(cStr)

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

Connection.Open "DSN=mysql_dsn"

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Response.Expires = -1000 'Makes the browser not cache this page
  3. Response.Buffer = True 'Buffers the content so our Response.Redirect will work
  4.  
  5. Dim Error_Msg
  6.  
  7. login = Request.Form("login")
  8. If login = "logout" Then
  9.     Session("UserLoggedIn") = ""
  10.     ShowLogin
  11. Else
  12.     If Session("UserLoggedIn") = "true" Then
  13.         AlreadyLoggedIn
  14.     Else 
  15.         If login = "true" Then
  16.             CheckLogin
  17.         Else
  18.             ShowLogin
  19.         End If
  20.     End If
  21. End If
  22.  
  23. Sub ShowLogin
  24. Response.Write(Error_Msg & "<br>")
  25. %>
  26. <form name=form1 action=login.asp method=post>
  27. User Name : <input type=text name=username><br>
  28. Password : <input type=password name=userpwd><br>
  29. <input type=hidden name=login value=true>
  30. <input type=submit value="Login">
  31. </form>
  32. >%
  33. End Sub
  34.  
  35. Sub AlreadyLoggedIn
  36. %>
  37. You are already logged in.
  38. Do you want to logout or login as a different user?
  39. <form name=form2 action=login.asp method=post>
  40. <input type=submit name=button1 value="Yes">
  41. <input type=hidden name=login value="logout">
  42. </form>
  43. %>
  44. End Sub
  45.  
  46. Sub CheckLogin
  47. Dim Conn, cStr, sql, RS, username, userpwd
  48. username = Request.Form("username")
  49. userpwd = Request.Form("userpwd")
  50. Set Conn = Server.CreateObject("ADODB.Connection")
  51. cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
  52. cStr = cStr & "DBQ=" & Server.MapPath("\path\to\database.mdb") & ";"
  53. Conn.Open(cStr)
  54. sql = "select a from admin where a = '" & LCase(username) & "'"
  55. sql = sql & " and b = '" & LCase(userpwd) & "'"
  56. Set RS = Conn.Execute(sql)
  57. If RS.BOF And RS.EOF Then
  58.     Error_Msg = "Login Failed. Try Again."
  59.     ShowLogin
  60. Else
  61.     Session("UserLoggedIn") = "true"
  62.     Response.Redirect "pages.asp"
  63. End If
  64. End Sub
  65. %>
Sep 15 '08 #1
Share this Question
Share on Google+
1 Reply


jeffstl
Expert 100+
P: 432
mySQL conn strings

Try this. If you make changes and still cannot resolve your connection let me know.
Sep 16 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.