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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need some help with some ASP code I am using...

    Hi,

    I have only been learning ASP for several days now and am hoping to become a professional web designer.

    I used the following code for my page - it does not come up with any errors and I used basically the same code for another page (which does work), but this page does not work as it will not submit comments from the form into the database. I would be very grateful for any help anyone could give me.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Comments</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <% 
    Dim adoCon
    Dim rscomments
    Dim SQL
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Mode=admodesharedenynone
    adoCon.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=d:\websites/clarkeyboy/datasource/comments.mdb")
    Set rscomments = Server.CreateObject("ADODB.Recordset")
    SQL = "SELECT comments FROM comments"
    rscomments.CursorType = 2
    rscomments.LockType = 3
    rscomments.Open SQL, adoCon
    %>
    <form>
    <strong>
    Comments: (Place your comments here and press enter)
    </strong>
    <input type="text" rows="20" cols="150" name="comment">
    </form>
    <table align="center" border="3" width="100%">
    <tr>
    <td width="10%">
    <b>
    <center>
    Comment Number
    </center>
    </b>
    </td>
    <td width="90%">
    <b>
    <center>
    Comments
    </center>
    </b>
    </td>
    </tr>
    <%
    Dim x
    x = 0
    Do While not rscomments.EOF
    %>
    <tr>
    <td width="50%">
    <%
    x = x + 1
    Response.Write(x)
    %>
    </td>
    <td width="50%">
    <%
    Response.Write (rscomments("comments"))
    %>
    </td>
    </tr>
    <%
    rscomments.MoveNext
    Loop
    %>
    </table>
    <%
    Dim strcomment
    strcomment = Request.Form("comment")
    Dim strNothing
    strNothing = ""
    If strcomment = strNothing Then
    Response.Write("Please submit a comment")
    Else
    rscomments.addnew
    rscomments("comments") = strComment
    rscomments.update
    Response.Redirect"comments.asp"
    Response.Write("Thank you for submitting a comment")
    End If
    rscomments.Close
    %>
    </body>
    </html>
    Displaying the information from the database works fine - so the connection is definitely there - but I can't get it to create new records.

    I have a database called comments, a table called comments and the column being taken from the table is also called comments - not necessarily a very good combination to call them all comments but its easy to handle at this stage.

  • #2
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok... Solved it - never put the method in for the form as I didn't know quite how important it was. What EXACTLY does the "post" method actually do? And how do you use the "get" method?

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Post submits data.
    You retrieve it using Request.Form("var")

    Get grabs data using the querystring
    http://www.domain.com/page.asp?id=1&user=joe

    id = Request.QueryString("id")
    user = Request.QueryString("user")

    http://www.w3schools.com/asp/asp_ref_request.asp


  •  

    Posting Permissions

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