Results 1 to 7 of 7
  1. #1
    Join Date
    May 2004
    Posts
    4

    Unhappy Unanswered: Connecting ASP to MySQL DB not working

    Hi,

    I have been trying to connect my ASP page to my MySQL DB for days and as a newbie to connecting to MySQL and using MySQL... It's not working and I'm at my wits end! Please help!

    This is my code with connection script and how I'm using it...

    <%Response.buffer = true%>
    <HTML>
    <head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <%

    'create connection, recordset objects
    var rsEvents = Server.CreateObject("ADODB.Recordset");
    rsEvents.ActiveConnection = "Driver={MySQL};DATABASE=dbname;UID=username;PASSW ORD=password;";

    SQL= "SELECT * FROM NEWS;"
    rs.Open SQL, ActiveConnection, 1

    %>

    <body>
    <p class="shadow">News Board</P>
    <table width="100%">
    <tr>
    <td>TITLE</td>
    <td>PUBLICATION DATE</td>
    <td>PARAGRAPH 1</td>
    <td>PARAGRAPH 2</td>
    <td>PARAGRAPH 3</td>
    <td>PARAGRAPH 4</td>
    <td>PARAGRAPH 5</td>
    <td>PARAGRAPH 6</td>
    <td>PARAGRAPH 7</td>
    <td>PARAGRAPH 8</td>
    </tr>
    <%
    IF not rs.eof Then
    rs.MoveFirst
    do while not rs.eof
    %>
    <tr>
    <td><%=rs.Fields.item("TITLE").Value%></td>
    <td><%=rs.Fields.item("PUB_DATE").Value%></td>
    <td><%=rs.Fields.item("PARA1").Value%></td>
    <td><%=rs.Fields.item("PARA2").Value%></td>
    <td><%=rs.Fields.item("PARA3").Value%></td>
    <td><%=rs.Fields.item("PARA4").Value%></td>
    <td><%=rs.Fields.item("PARA5").Value%></td>
    <td><%=rs.Fields.item("PARA6").Value%></td>
    <td><%=rs.Fields.item("PARA7").Value%></td>
    <td><%=rs.Fields.item("PARA8").Value%></td>
    </tr>
    <%
    rs.MoveNext
    Loop
    END IF
    %>
    </table>

    My host account uses chillisoft ASP as its linux based, and this is the format they tell us to connect to MySQL with.

    Please help?!

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    What is the error you're getting?
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    May 2004
    Posts
    4
    I'm not getting any error, just a server timeout.

    There are currently only two rows in the database so it can only be the connection I reckon.

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    I'm not familair with chillisoft, but in traditional ASP you don't end a line with a semi-colon.. are you sure that's proper syntax in chillisoft ASP?
    That which does not kill me postpones the inevitable.

  5. #5
    Join Date
    May 2004
    Posts
    4
    Semi-colon where? which line?

    I know what you mean. I'm used to connecting to a SQL Server 2000 DB and don't end my queries with a semi-colon usually if that was what you meant.

  6. #6
    Join Date
    May 2004
    Posts
    4

    Unhappy

    I've changed my connection and query now to be more precise:

    set conn=Server.CreateObject("ADODB.Connection")
    ConnectionString = "Driver={MySQL}; Database=dbname; UID=username; PWD=password"

    conn.open (ConnectionString)
    set result=Server.CreateObject("ADODB.Recordset")

    SQL= "SELECT TITLE, PUB_DATE, PARA1, PARA2, PARA3, PARA4, PARA5, PARA6, PARA7, PARA8"
    SQL = SQL & "FROM NEWS "

    set result = conn.execute(SQL)

    I'm still getting a time out. I don't undestand.

  7. #7
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    You need a space before "FROM", otherwise PARA8 and FROM run together...

    But that would generate a different error... If you don't execute the SQL, does it still time out?
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •