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 9 of 9

Thread: Help

  1. #1
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Help

    I've been trying all day to get this work, im fairly new at asp, and I need some help, im making a page that is going to take data from a access database using an sql query based on user input. Basically, i want this to display the info in a row in my table. Here is what i have, but i dont know how to get it to take the user input, what should i do

    <%
    Response.Buffer = true
    dim cnn,rst
    set cnn = Server.CreateObject("ADODB.Connection")
    set rst = Server.CreateObject("ADODB.RecordSet")
    cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:\inetpub\wwwroot\data.mdb;"
    strType=Request.form("id1")
    sqltext = "SELECT * FROM tbl1 WHERE id=& strType &"
    set rst = cnn.Execute(sqltext)
    Response.Write rst("id")
    Response.Write rst("submitted_by")
    Response.Write rst("date")
    Response.Write rst("department")
    Response.Write rst("date_required_go_live")
    %>

    It works fine without the varible in there, so, please help

  • #2
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, if you need an example of what i am trying to do, here is a link:

    [url]http://www.aspalliance.com/aspxtreme/ado/structuredquerylanguagebasics.aspx?pageno=0

    Its the one with the drop down box

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Depending on the datatype of id, try either:

    sqltext = "SELECT * FROM tbl1 WHERE id=" & strType

    or

    sqltext = "SELECT * FROM tbl1 WHERE id='" & strType & "'"

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but, now i have a new problem, its the same type i believe, I cant get the variable to work, and I dont know why

    <%
    ' Setting variables
    Dim con, sql_update, data_source
    data_source = "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:\inetpub\wwwroot\data.mdb;"
    formid = "Request.Form('prodType')"
    sql_update = "update tbl1 set submitted_by = 'Update Records' where id = "& formid &""

    ' Creating the Connection Object and opening the database
    Set con = Server.CreateObject("ADODB.Connection")
    con.Open data_source

    ' Executing the sql update code
    con.Execute sql_update

    ' Done. Now Close the connection
    con.Close
    Set con = Nothing
    %>


    I get the same error message as before

    BTW, i was able to resolve my last problem

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Again, your SQL statement looks wrong...

    sql_update = "update tbl1 set submitted_by = 'Update Records' where id = " & formid
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That didnt work, I changed it to what you had and got this error message:

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Undefined function 'Request.Form' in expression.

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try writing out your SQL statements when you get errors, i.e.:

    SQL = "SELECT * FROM WHATEVER"
    Response.Write(SQL) : Response.End

    The reason it isn't working is because of this:

    formid = "Request.Form('prodType')"

    Request.Form("") shouldn't have quotes around it, you're turning that into a string that equals "Request.Form('prodType')".

    that line should be:

    formid = Request.Form("prodType")

    It looks like you're having a lot of problems with the syntax, writing out your SQL statements when they error will show you what's being generated.
    Last edited by whammy; 01-26-2003 at 05:10 PM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #8
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Didnt work again, I got this error message this time:

    Syntax error (missing operator) in query expression 'id ='.


    If i remove all of the variables the script works fine, the form is not inside the asp page, does it need to be? right now it is an external file

  • #9
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind, I got it to work. Thanks for all your help
    Last edited by psyc635; 01-26-2003 at 09:25 PM.


  •  

    Posting Permissions

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