Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Sending Data to a Database

  1. #11
    Join Date
    Jun 2003
    Posts
    277
    Rep Power
    0

    Default Re:Sending Data to a Database

    Guys Guys Guys


    Take it easy...

    Cant we all just get along!

    Anyway, i'm trying to build my knowledge of both ASP and PHP concurrently...so you'll see me in both forums. But i need ASP for a specific project...

    I progressed in terms of not seeing any more ASP errors;
    but the database is not being updated with the test data...

    Other than checking the executable permissions on the server,

    is there any other explanation as to why this is occurring?

  2. #12
    igodit Guest

    Default Re:Sending Data to a Database

    Well Cue we need some more information. Show us the error you are getting.

    Oh! And guys

  3. #13
    Join Date
    Jun 2003
    Posts
    277
    Rep Power
    0

    Default Re:Sending Data to a Database

    Ok folks

    here's the Hizzie for shizzie!

    My code is almost identical to what IGODIT posted...

    view

    Code:
    <% @Language=VBScript%>
    <% Option Explicit %>
    
    <!--#include file="adovbs.inc"-->
    <!--#include file="connection.asp"-->
    
    <%
    
    Dim objRS, Lname, Fname, MIname, address1, country, address2, phonecontact1, phonecontact2, phonecontact3, req1
    
    
          Lname=trim(request.form("Lname"))
             Fname=trim(request.form("Fname"))
                address1=trim(request.form("address1"))
                address2=trim(request.form("address2"))
                   req1=trim(request.form("req1"))
    
             
          If Lname = "" then
             response.redirect "createuser.asp?error=1"
          else
             If Fname = "" then
                response.redirect "createuser.asp?error=1"
             If address1 = "" then
                response.redirect "createuser.asp?error=1"
             If address2 = "" then
                response.redirect "createuser.asp?error=1"
             If req1 = "" then
                response.redirect "createuser.asp?error=1"
             End If
             End If
             End If
             End If
          End If
    
    
    
    
    Set objRS = Server.CreateObject("ADODB.Recordset")
    
    
    
    objRS.Open "select top 1 * from [tbl]", objConn, adLockOptimistic, adCmdTable
    
    objRS.AddNew
    
    objRS("Lname") = Request.Form("Lname")
    objRS("Fname") = Request.Form("Fname")
    objRS("MIname") = Request.Form("MIname")
    objRS("address1") = Request.Form("address1")
    objRS("country") = Request.Form("country")
    objRS("address2") = Request.Form("address2")
    objRS("phonecontact1") = Request.Form("phonecontact1")
    objRS("phonecontact2") = Request.Form("phonecontact2")
    objRS("phonecontact3") = Request.Form("phonecontact3")
    objRS("req1") = Request.Form("req1")
    
    Set objRS = nothing
    objConn.Close
    Set objConn = nothing
    
    
    Response.redirect "createuser2.asp?success=1"
    
    
    %>

    The Createuser files are confirmation messages
    and the includes ...well... IGODIT said it best... you all should know what the includes are...
    "Lname etc" are the field names...

    I dont get any errors in running the code.

    But i also dont see any results in my table.

    Thats the prob

  4. #14
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default Re:Sending Data to a Database

    Where's the objRS.Update code? If you don't update the data to the database, it will never reach the database.

    Code:
    ...
    objRS("phonecontact3") = Request.Form("phonecontact3")
    objRS("req1") = Request.Form("req1")
    objRS.Update
    
    ...

  5. #15
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default Re:Sending Data to a Database

    Why not change this bit of code:
    Code:
    If Lname = "" then
             response.redirect "createuser.asp?error=1"
          else
             If Fname = "" then
                response.redirect "createuser.asp?error=1"
             If address1 = "" then
                response.redirect "createuser.asp?error=1"
             If address2 = "" then
                response.redirect "createuser.asp?error=1"
             If req1 = "" then
                response.redirect "createuser.asp?error=1"
             End If
             End If
             End If
             End If
          End If
    to this:
    Code:
    If Lname = "" then
       response.redirect "createuser.asp?error=1"
    End If
    If Fname = "" then
       response.redirect "createuser.asp?error=1"
    End If
    If address1 = "" then
       response.redirect "createuser.asp?error=1"
    End If
    If address2 = "" then
       response.redirect "createuser.asp?error=1"
    End If
    If req1 = "" then
       response.redirect "createuser.asp?error=1"
    End If
    It's much neater and more readable. Not to mention does the same thing.

  6. #16
    igodit Guest

    Default Re:Sending Data to a Database

    Shizzle ma' tech nizzle... Go through Arch_angel schooling him I see..

    Cue format your code the way Arch_angel did it, so that you don't get too confused... especially when you may have people helping you. Looking for END IF statments that are all over the place can take too much time that can be use to resolve a problem.

    Do the Update for the record in the database and you should know, your "Good to Go!"

  7. #17
    Join Date
    Jun 2003
    Posts
    277
    Rep Power
    0

    Default Re:Sending Data to a Database

    Thanks ppl for you help


    Got the code running after one last hitch

    After putting in the update query
    i remembered why it wasnt there in the first place

    In an effort to debug...i had removed the query because i kept getting an OBDC error from that line of code.

    Once i put it back i got the same error again
    but i got the fix from microsoft...

    you guys can view it here for general knowledge: http://support.microsoft.com/support.../Q175/1/68.ASP

    AAHHH...ASP is fun... (Not to take anything from PHP ---for those still touchy on the subject! )

    Thanks again

  8. #18
    Join Date
    Sep 2003
    Posts
    42
    Rep Power
    0

    Default Re:Sending Data to a Database

    Here's a couple URLs that can guide u in the right direction.

    http://msdn.microsoft.com/library/de.../asptshoot.asp

    http://msdn.microsoft.com/library/de...riVBScript.asp

    Here's a good book also. It's old (ASP 3.0), but it's a good start to get u up to speed.

    http://www.wrox.com/books/0764543636.shtml

Posting Permissions

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