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 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2004
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting a confirmation of SQL upload on ASP page.

    Hello, I have a ASP page that takes data from a form and uploads it to a MSsql DB. I would like to added a "confirmation script" that will verify the update against the db and then display a confirmation page. I have ran accross a coupl of instances of uploading entries and it says it uploaded it OK but it really didn't even touch the Db... here's my Code where it takes the form data ans the updates the recorded select:

    Code:
    <html>
    <head>
    <meta name="keywords" content="DoNotBrowse">	
    <title= KATRINA - Form Processing</title>
    </head>
    
    	<body bgcolor="#ffffff">
    <%
    
    dated=Request.Form("dated")
    id=Request.Form("id")
    timed=Request.Form("timed")
    hmg=Request.Form("hmg")
    inncode=Request.Form("inncode")
    fname=Request.Form("fname")
    lname=Request.Form("lname")
    ssnum=Request.Form("ssnum")
    hotel=Request.Form("hotel")
    empnum=Request.Form("empnum")
    add1=Request.Form("add1")
    add2=Request.Form("add2")
    city=Request.Form("city")
    state=Request.Form("state")
    zip=Request.Form("zip")
    Phone1=Request.Form("Phone1")
    Phone2=Request.Form("Phone2")
    Phone3=Request.Form("Phone3")
    datestop=Request.Form("datestop")
    checksent=Request.Form("checksent")
    otherinfo = request.form("otherinfo")
    otherinfo = replace (otherinfo, "'", "''")
    fammem = request.form("fammem")
    fammem = replace (fammem, "'", "''")
    operations = request.form("operations")
    operations = replace (operations, "'", "''")
    lastcontactdate = request.form("lastcontactdate")
    locatedfamily = request.form("locatedfamily")
    needshousingassist = request.form("needshousingassist")
    HousingLocation = request.form("HousingLocation")
    housingdstatus = request.form("housingdstatus")
    requiresjobassist = request.form("requiresjobassist")
    JobLocation = request.form("JobLocation")
    JobLocation = replace (JobLocation, "'", "''")
    JobDept = request.form("JobDept")
    JobDept = replace (JobDept, "'", "''")
    JobPosition = request.form("JobPosition")
    JobPosition = replace (JobPosition, "'", "''")
    FLSA = request.form("FLSA")
    Jobstatus = request.form("Jobstatus")
    Job_NoAssistance = request.form("Job_NoAssistance")
    Job_NoAssistance = replace (Job_NoAssistance, "'", "''")
    PR_AssistanceYN = request.form("PR_AssistanceYN")
    PR_AssistanceStatus = request.form("PR_AssistanceStatus")
    BE_AssistanceYN = request.form("BE_AssistanceYN")
    BE_AssistanceStatus = request.form("BE_AssistanceStatus")
    return2NO = request.form("return2NO")
    WorkatHotel = request.form("WorkatHotel")
    NeedTempHousing = request.form("NeedTempHousing")
    emailaddress = request.form("emailaddress")
    emailaddress = replace (emailaddress, "'", "''")
    termdate = request.form("termdate")
    termdate = replace (termdate, "'", "''")
    medcov = request.form("medcov")
    temporPerm = request.form("temporPerm")	
    
    
    
    'Connect to database to upload all form data.  
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "Provider=SQLOLEDB;Data Source=xx.xx.xxx.xxx;database=xxxxxxxxx;uid=xxxxxx;pwd=xxxxxxx;"
    
    
    update1 = "UPDATE dbo_Log_Table SET Firstname = '"&fname&"', Lastname = '"&lname&"',"
    update1 = update1 & "SSN = '"&ssnum&"', EmployeeNum = '"&empnum&"', Hotel = '"&Hotel&"', Phone1 = '"&Phone1&"',"
    update1 = update1 & "Phone2 = '"&Phone2&"', Phone3 = '"&Phone3&"', Address_Line_1 = '"&add1&"',"
    update1 = update1 & "Address_Line_2 = '"&add2&"', City = '"&City&"', state = '"&state&"',"
    update1 = update1 & "zip = '"&zip&"', DaytoStopSendingCheckHere = '"&datestop&"', Otherinfo = '"&otherinfo&"', "
    update1 = update1 & "Family_Member_Info = '"&fammem&"', hmg = '"&hmg&"', Inncode = '"&inncode&"', Checksent = '"&checksent&"', Operations = '"&operations&"',"
    update1 = update1 & "lastcontactdate = '"&lastcontactdate&"',locatedfamily = '"&locatedfamily&"',needshousingassist = '"&needshousingassist&"',"
    update1 = update1 & "HousingLocation = '"&HousingLocation&"',housingdstatus = '"&housingdstatus&"',requiresjobassist = '"&requiresjobassist&"',"
    update1 = update1 & "JobLocation = '"&JobLocation&"',JobDept = '"&JobDept&"',JobPosition = '"&JobPosition&"',FLSA = '"&FLSA&"',Jobstatus = '"&Jobstatus&"',"
    update1 = update1 & "Job_NoAssistance = '"&Job_NoAssistance&"',PR_AssistanceYN = '"&PR_AssistanceYN&"',PR_AssistanceStatus = '"&PR_AssistanceStatus&"',"
    update1 = update1 & "BE_AssistanceYN = '"&BE_AssistanceYN&"',BE_AssistanceStatus = '"&BE_AssistanceStatus&"',return2NO = '"&return2NO&"',"
    update1 = update1 & "WorkatHotel = '"&WorkatHotel&"',NeedTempHousing = '"&NeedTempHousing&"', emailaddress = '"&emailaddress&"', termdate = '"&termdate&"', medcov = '"&medcov&"', temporPerm = '"&temporPerm&"'"
    update1 = update1 & " WHERE  id = '"&id&"'"
    set objRS=Conn.execute(update1) 
    
    %>
    <CENTER>
    			<BR>
    			<font size="3" face="Arial"><BR><BR><BR><BR>
    Successfully Updated Database. -- THANK YOU!<BR>
    <a href="../main.htm">Back to the Main Menu</a></center></SPAN>
    			</font>
    </center>
    <BR><BR><BR><BR>
    
    
    </body>
    
    </html>

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    set objRS=Conn.execute(update1)


    Change that bit. You don't need to create a recordset, and you can pass a variable into the Execute method that'll tell you if any rows got populated:

    dim intRowsAffected : intRowsAffected = 0
    Conn.execute update1, intRowsAffected
    If intRowsAffected > 0 then
    'woohoo
    else
    'meh
    end if


  •  

    Posting Permissions

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