3

I am trying to connect to a remote MySQL database from Classic ASP page, when I write VBScript code in it the website is giving HTTP 500 Internal Server Error. I checked with the host they are saying its not an error from their end.

Please help me.

<%
dim myConnection
dim connectString

username = "bla"
password = "bla"
database = "bla"
host = "bla"

Set myConnection = Server.CreateObject("ADODB.Connection")
Set RSTitleList = Server.CreateObject("ADODB.Recordset")

connectString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER="&host&"; DATABASE="&database&"; UID="&username&";PASSWORD="&password&"; OPTION=3"

**myConnection.Open connectString   ---- HERE I'M GETTING ERROR. ABOVE CODE IS WORKING FINE.**

Set RSTitleList =  myConnection.Execute( "Select * From questions") %>


<!-- Begin our column header row -->  

<!-- Ok, let's get our data now -->
<% do while not RStitleList.EOF %>   
   <p>           <%=RStitleList("id")%>).

             <b><%=RSTitleList("question") %></b>  &nbsp&nbsp&nbsp&nbsp <%=RSTitleList("answer") %> <!--<a href="emailaddress.htm">-->More&#9658;<!--</a>--> <br>
             <p>&nbsp&nbsp&nbsp&nbsp <font color="purple"> answered by </font> <b>Sadhu</b> on 1-10-2015 </p>   
    </p>


   <% RSTitleList.MoveNext%>

<%loop %>
user692942
  • 16,398
  • 7
  • 76
  • 175
  • 1
    Read through and implement [Detailed 500 error message, ASP + IIS 7.5](http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5) to see what the exact error is. – Flakes Nov 30 '15 at 06:34
  • Hello the server where my website is a remote server and I dont have access to it.. thank you for the information though – Indian knight Nov 30 '15 at 06:36
  • An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error. I am getting this error when I modified the web.config file – Indian knight Nov 30 '15 at 06:42
  • can you try connecting to the db using some other tool,using the same credentials? – Flakes Nov 30 '15 at 06:47
  • Yes I am able to. The db is working fine its just that ".open in the above code" is giving the error I guess. Earlier the same code worked and I was able to connect to the database but very recently it started to give error 500. I dont know why – Indian knight Nov 30 '15 at 06:49
  • Ask your host if they have the 3.51ndriver installed – Flakes Nov 30 '15 at 06:51
  • sounds like a good Idea, Let me check and will get back to you. Thanks SearchAndResQ – Indian knight Nov 30 '15 at 06:52
  • 2
    Dude - "Error 500" means exactly what is says: the error is on the *SERVER SIDE*. You absolutely need to check the IIS logs, the MySQL logs and you absolutely need to identify the server-side error. Doing *anything* else before you have a *clear error message* is just a blind "shot in the dark". – paulsm4 Nov 30 '15 at 06:53
  • 2
    "I checked with the host they are saying its not an error from their end" - it absolutely *is* on their end, as paulsm4 said. It may not be their *fault*, but it is on their *end*. It is completely pointless for you to do anything until and unless your host enables detailed error messages. – Martha Nov 30 '15 at 18:01
  • 1
    I had a word with my host and this what they have said "We've found the following error : [MySQL][ODBC 3.51 Driver]Access denied for user 'bla'@'162.253.126.112' (using password: YES) /ehr/ElectronicHealthRecordsEHREMRIntro.asp, line 165 As we see db "qtoa" is hosted on "db4free.net" Kindly check it from your side and let us know how we can help you further. " – Indian knight Nov 30 '15 at 18:10
  • Q: Have you resolved the authentication problem yet? Q: Has your provider given you a way to manage mySQL users and passwords, and can you store them in your web app (for example, as a [data source](http://www.tutorialspoint.com/asp.net/asp.net_data_sources.htm))? – paulsm4 Dec 02 '15 at 21:21

1 Answers1

0

OK, you've found the underlying error message (on the server). Thank you. It's important:

 [MySQL][ODBC 3.51 Driver]Access denied for user 'bla'@'162.253.126.112' (using password: YES) 

Since you're getting "access denied", and since a MySQL identity" is a combination of username + host, this means one of three things:

  1. You're passing mySQL the wrong username...

  2. ... And/or you're logging in from a host that hasn't been granted access...

  3. ... And/or you're passing mySql the wrong password

Normally, the best way to troubleshoot would be with the mysql command-line client. I'm guessing this is probably not an option for you.

Another way might be Control Panel > ODBC > Test Connection:

But this might not an option either, if your IIS webserver and MySQL database are co-located on the remote server (instead of local).

Here are some other suggestions for troubleshooting your mySQL username/password:

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190