SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    Syracuse
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with an update

    I'm going to apologize in advance, because I know I'm missing something obvious and dumb here.

    I'm trying to use a form to update a record (here's a snip)

    Code:
     <form ACTION="supplemental_form.asp" METHOD="POST" name="supplemental">
    <input type = "hidden" name = "mode" value = "update">
    <table width="100%" border="1">
    <tr bgcolor="#ffccbb"> 
    <td colspan="2"><h3>Degree Information</h3></td>
    </tr>
    <tr>
    <td width="40%"><strong>Do You Have a Bachelor's Degree:</strong></td>
    <td><input type="radio" name="ce_has_degree" value="yes">Yes &nbsp;&nbsp;&nbsp;<input type="radio" name="ce_has_degree" value="no"> No
    </td>
    </tr>
     <tr bgcolor="#ffccbb"> 
    <td colspan="4"> <div align="center"> 
    <input type="submit" name="Submit" value="Submit Your Registration">
                      &nbsp; &nbsp; &nbsp; &nbsp; 
                      <input type="reset" name="Submit2" value="Start Again ">
    </div></td>
    </tr>
    </table>
    <input type="hidden" name="update" value="supplemental">
    </form>
    Here's what I'm trying to use to update the record:
    Code:
    <%
    ssql = "Update ce_reg_info Set ce_has_degree='ce_has_degree', ce_earned_degree='ce_earned_degree', ce_catholic_school='ce_catholic_school', ce_diocesean_school='ce_diocesean_school', ce_needs_transportation='ce_needs_transportation', ce_airline='ce_airline', ce_arrival_date='ce_arrival_date', ce_arrival_time='ce_arrival_time', ce_departure_date='ce_departure_date', ce_departure_time='ce_departure_time', ce_car_make='ce_car_make', ce_car_model='ce_car_model', ce_car_color='ce_car_color', ce_car_license_nor='ce_car_license_no'"
    
    rs = "select * from ce_reg_info"
    	filekey = rs("ce_reg_id")
    		redirectline = "non_credit_bill.asp?filekey=" & filekey
    		redirectline = redirectline & "&card=" & cardnum
    		redirectline = redirectline & "&auth=" & auth
    		redirectline = redirectline & "&amt=" & payamt
    		response.redirect redirectline
    		response.end
    	
    	%>
    I'm getting a Microsoft VBScript runtime error '800a000d'

    Type mismatch
    supplemental_form.asp, line 175
    which is the filekey line

    I'm trying to rebuild someone's code and know I've missed something.

    Thanks in advance.

    Michelle

  2. #2
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Sheffield, UK
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are assigning a string of SQL to the variable RS then treating the variable as an ADODB.Recordset ActiveX object.

    You need to execute the query on an ADODB.Connection object to get a Recordset back. This Article covers getting data out of a database using ASP classic quite nicely. Try that.
    Last edited by THEMike; Apr 5, 2005 at 08:18. Reason: Type-o in the url bb code

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    Syracuse
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - that helped a lot. Here's what I did instead:

    Code:
    set cn=server.CreateObject("ADODB.connection")
    	cn.open("dsn=mmm;database=mmm;uid=mmm;pwd=mmm;")
    	filekey	= request("filekey")
    
    	ssql = "select * from ce_reg_info where ce_reg_id = " & filekey
    	
    cn.execute = "Update ce_reg_info Set ce_has_degree='ce_has_degree', ce_earned_degree='ce_earned_degree' where ce_reg_id=" & filekey
    strSQL = "select * from ce_reg_info where ce_reg_id = " & filekey
    set rs2 = cn.execute(strSQL)
    
    redirectline = "non_credit_bill.asp?filekey=" & filekey
    response.redirect redirectline
    response.end
    But now it gives me a Microsoft OLE DB Provider for ODBC Drivers error '80040e57'
    [Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated.
    supplemental_form.asp, line 14 (which is the cn.execute line)

    Any additional suggestions?

    Thanks

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your code you're attempting to execute a query, but right after that you're redirecting to another page.

    It looks like you're not using the data coming from the query at all.

  5. #5
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Sheffield, UK
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AS the previous poster pointed out, you don't actually need to open the recordset.

    AS for the error you are getting, I think the problem is that your ce_has_degree and ce_earned_degree's must be yes/no fields in access. Or bit fields in SQL. You are setting them to strings, rather than the content of the form, what you need really is:

    Code:
    If Request("ce_has_degree") = "yes" Then
      blnCEHasDegree = True
    Else
      blnCEHasDegree = False
    End If
    
      set cn=server.CreateObject("ADODB.connection")
      cn.open("dsn=mmm;database=mmm;uid=mmm;pwd=mmm;")
      filekey	= request("filekey")
    
    strSQL = "UPDATE ce_reg_info SET ce_has_degree=" & blnCEHasDegree & " WHERE ce_reg_id=" & filekey
    
      cn.execute strSQL
    
      redirectline = "non_credit_bill.asp?filekey=" & filekey
      response.redirect redirectline
      response.end


Bookmarks

Posting Permissions

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