Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax error - Invalid Character

    Hi all, can anyone tell me what's wrong with this line of code??

    Invalid character
    /fyp_actual/sqlconn.asp, line 9, column 7
    DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;");
    ------^

    Thanks!

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    did you put double quotes around the string?

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nope that was exactly what i entered - no double quotes. what's wrong with that statement??

    DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Well you should have enclosed the string like so
    sConn = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"

  • #5
    Regular Coder
    Join Date
    Oct 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OH well apparently i just did this in my whole file:

    <%
    driver{ .....}
    %>

    no wonder it doesn't work.

    do you have exactly what is needed to complete the whole thing? I know something like db.open or db.close ... or something =x Or is there a website for me to refer to? =( cos actually i'm trying to access an external database which is stored inside my web hosting company's server ... .so .. i'm not sure if there are any other things i need to take care of?

    Thanks so much ....
    Last edited by plasterx; 03-23-2006 at 02:38 AM.

  • #6
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Let me rephrase this. ADD the Quotes around the string!!!! the following is a string NOT a variable, therefore it must be enclosed in quotes.
    Code:
    DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;
    should be
    Code:
    "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"
    IT doesn't matter if it is a remote database server or a database server on the same server that the webserver resides on.

  • #7
    Regular Coder
    Join Date
    Oct 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i think i got it. But currently my file only has this line:
    <%
    "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"
    %>

    Do i need to have something like this:

    conn = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"
    conn.open

    or something? Or will those original lines do?

  • #8
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    that is the connection string. You still need to have a connection object and/or a recordset object. below are 3 different examples. In these examples I will get the orderid and also the quantity of widgets sold from the widgets table where the widget color is blue



    example using both the connection object and the recordset object
    Code:
    Dim sConnStr, oConn, oRs, sSQL
    sConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"
    Set oConn = Server.CreateOBject("ADODB.Connection")
    oConn.Open sConnStr
    Set oRs = Server.CreateObject("ADODB.Recordset")
    sSQL = "SELECT * FROM widgets WHERE color = 'blue'"
    oRs.Open sSQL, oConn, 0, 1
    If Not oRs.EOF Then
    	While Not oRs.EOF
    		Response.Write "Order Number: " & oRs("orderID") & "<br>" & vbCrLf
    		Response.Write "Quantity: " & oRs("quantity") & "<br><br>" & vbCrLF	
    	Wend
    End If
    oRs.Close
    Set oRs = Nothing
    oConn.Close
    Set oConn = Nothing

    Example only using the connection object and it's execute method
    Code:
    Dim sConnStr, oConn, oRs, sSQL
    sConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"
    Set oConn = Server.CreateOBject("ADODB.Connection")
    oConn.Open sConnStr
    sSQL = "SELECT * FROM widgets WHERE color = 'blue'"
    Set oRs = oConn.Execute(sSQL)
    If Not oRs.EOF Then
    	While Not oRs.EOF
    		Response.Write "Order Number: " & oRs("orderID") & "<br>" & vbCrLf
    		Response.Write "Quantity: " & oRs("quantity") & "<br><br>" & vbCrLF	
    	Wend
    End If
    oRs.Close
    Set oRs = Nothing
    oConn.Close
    Set oConn = Nothing

    Lastly using only the recordset object
    Code:
    Dim sConnStr, oRs, sSQL
    sConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=fyp;UID=sa;PWD=;"
    Set oRs = Server.CreateObject("ADODB.Recordset")
    sSQL = "SELECT * FROM widgets WHERE color = 'blue'"
    oRs.Open sSQL, sConnStr, 0, 1
    If Not oRs.EOF Then
    	While Not oRs.EOF
    		Response.Write "Order Number: " & oRs("orderID") & "<br>" & vbCrLf
    		Response.Write "Quantity: " & oRs("quantity") & "<br><br>" & vbCrLF	
    	Wend
    End If
    oRs.Close
    Set oRs = Nothing


  •  

    Posting Permissions

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