Connect Remote ASP to Remote MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munro01
    New Member
    • Jan 2012
    • 3

    Connect Remote ASP to Remote MySQL

    In ASP I am using a DNS-less connection (see code below: with the log in credentials filtered).

    Code:
    <%
    on error resume next
    
    dim csmp_conn
    dim adoRS
    dim counter
    
    set csmp_conn = Server.CreateObject("ADODB.Connection")
    set adoRS = Server.CreateObject("ADODB.Recordset")
    csmp_conn.Open "Driver={MySQL ODBC 5.1 Driver}; Server=XXXXX; Database=XXXXX; Uid=XXXXX; Pwd=XXXXX;"
    
    adoRS.ActiveConnection = csmp_conn
    
    
    response.write "<h2>Number of Records in MyTable: </h2>"
    adoRS.Open "SELECT * FROM myTable"
    	
    ' Count how many records exist
    dim iRecordCount
    iRecordCount = 0
    DO WHILE NOT adoRS.EOF
    iRecordCount = iRecordCount + 1
    adoRS.MoveNext
    Loop
    	
    ' Display result
    Response.Write "Record Count:(" & iRecordCount & ")"
    	
    adoRS.Close
    Set adoRS = Nothing 	
    
    %>
    Testing the connection string and executing the sample query works fine locally but the problem comes when I test the same file on my hosting site's server. It appears that the page is not getting access to the remote database by so doing it returns an error but I am not entirely sure why this is the case.

    If anyone has ever come across this problem your input will be greatly appreciated.
    Last edited by munro01; Jan 23 '12, 08:38 PM. Reason: Images are not appearing.
  • C CSR
    New Member
    • Jan 2012
    • 144

    #2
    What is the error message? Or does it just crash?

    Comment

    • munro01
      New Member
      • Jan 2012
      • 3

      #3
      Hi sorry for the late response. I managed to find a solution to the problem. It was more of a system issue than the code itself.

      Comment

      Working...