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 1 of 1
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    Errors trying to add data to record

    Hello

    I have an 'Add Records' page which is malfunctioning. If I leave all fields blank, I get the following error:

    Microsoft VBScript runtime error '800a000d'

    Type mismatch: 'CDBL'

    /addRecords_TEST.asp, line 108
    Line 108 refers to this:
    Code:
    my_wolfID = CDBL( Request.Form("wolfID") )
    wolfID is a 'Numeric' data type in my MS Access database (please see screenshot).

    When I complete all fields except for wolfID, I get:

    Microsoft VBScript runtime error '800a000d'

    Type mismatch: 'CDBL'

    /addRecords_TEST.asp, line 108
    Again, line 108 refers to this:
    Code:
    my_wolfID = CDBL( Request.Form("wolfID") )
    When I 'mistakenly' type letters in the wolfID (Numeric) field and complete all other fields, I get:

    Microsoft VBScript runtime error '800a000d'

    Type mismatch: 'CDBL'

    /addRecords_TEST.asp, line 108
    Again, line 108 refers to this:
    Code:
    my_wolfID = CDBL( Request.Form("wolfID") )
    When I complete all fields as they should be completed, I get:

    Microsoft JET Database Engine error '80040e57'

    Overflow

    /addRecords_TEST.asp, line 125
    Line 125 refers to this:
    Code:
    connection.Execute sSQL
    If I then make the wolfID column in my MS Access database a 'Text' data type and replace 'CDBL' with 'Replace' (as with the other text fields
    in my code), I get the following error:

    Microsoft VBScript runtime error '800a01c2'

    Wrong number of arguments or invalid property assignment: 'Replace'

    /addRecords_TEST.asp, line 108
    Again, line 108 is this:
    Code:
    my_wolfID = Replace( Request.Form("wolfID") )
    So I insert this debugging line:

    Code:
    Response.Write "<hr/>DEBUG SQL:<br/>" & sSQL & "<hr/>" & vbNewLine
    and simply get a repetition of the error above:

    DEBUG SQL:

    Microsoft VBScript runtime error '800a01c2'

    Wrong number of arguments or invalid property assignment: 'Replace'

    /addRecords_TEST.asp, line 111
    It seems clear that the source of the problem lies in either this:
    Code:
    my_wolfID = CDBL( Request.Form("wolfID") )
    or this:
    Code:
    my_wolfID = Replace( Request.Form("wolfID") )
    What to do? I feel as if I have tried everything!

    This is the code as I have it at the moment:

    Code:
    <% Dim Connection, Recordset, sSQL, sConnString, fullName, wolfID, telNo, address, email, description, received, action, dispatched
    
    'Create and open Database Connection
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
    "Data Source=" & "E:\clients.mdb"
    
    Set connection = Server.CreateObject("ADODB.Connection")
    'create recordset object
    Set recordset = Server.CreateObject("ADODB.Recordset")
    'Open connection
    connection.Open sConnString
    
    Dim conn, rs, my_fullName, my_wolfID, my_telNo, my_address, my_email, my_description, my_received, my_action, my_dispatched
    ' set varaible values from request.form
    
    
    my_fullName = Replace( Request.Form("fullName"), "'", "''" )
    
    
    my_wolfID = Replace( Request.Form("wolfID") )
    
    
    my_telNo = CDBL( Request.Form("telNo") )
    my_address = Replace( Request.Form("address"), "'", "''" )
    my_email = Replace( Request.Form("email"), "'", "''" )
    my_description = Replace( Request.Form("description"), "'", "''" )
    my_received = CDATE( Request.Form("received") )
    my_action = Replace( Request.Form("action"), "'", "''" )
    my_dispatched = Replace( Request.Form("dispatched"), "'", "''" )
    
    'build insert statement
    sSQL="INSERT INTO tblWolf " &_
     "(fullName, wolfID, telNo, address, email, description, received, [action], dispatched)" &_
     " VALUES ('" & my_fullName & "', " & my_wolfID & ", " & my_telNo & ", '" & my_address & "', '" & my_email & "', '" & my_description & "', #" & my_received & "#, '" & my_action & "', '" & my_dispatched & "')"
    
    
    ' insert record
    connection.Execute sSQL
    
    Response.write "<div class='center'><p class='font'>The record has been added.</p></div>"
    
    ' build select SQL
    sSQL="SELECT TOP 20 ID, fullName, wolfID, telNo, address, email, description, received, action, dispatched FROM tblWolf ORDER BY ID DESC"
    ' open recordset
    recordset.Open sSQL,connection
    
    response.write "<table class='myTable'>"%>
    
    
    <tr class="headerRow">
                    <td>ID</td>
    		<td>Full Name</td>
    		<td>Wolf ID</td>
    		<td>Tel No</td>
                    <td>Address</td>
    		<td>Email</td>
    		<td>Description</td>
    		<td>Received</td>
                    <td>Action</td>
    		<td>Dispatched</td>    </tr>
    
    <%
    'write data from recordset to table
    If Recordset.EOF Then
        Response.Write "<tr><td>No records returned.</td></tr>"
     Else
        Do While Not recordset.EOF
    
            Response.Write "<tr><td>" & recordset("ID") & "</td>"
            Response.Write "<td>" & recordset("fullName") & "</td>"
            Response.Write "<td>" & recordset("wolfID") & "</td>"
            Response.Write "<td>" & recordset("telNo") & "</td>"
            Response.Write "<td>" & recordset("address") & "</td>"
            Response.Write "<td>" & recordset("email") & "</td>"
            Response.Write "<td>" & recordset("description") & "</td>"
            Response.Write "<td>" & recordset("received") & "</td>"
            Response.Write "<td>" & recordset("action") & "</td>"
            Response.Write "<td>" & recordset("dispatched") & "</td></tr>" 
            ' move to next record
            Recordset.MoveNext
         Loop
    'close recordset
    Recordset.close
     response.write "</table>"
     End If%>
    
    <% 'close connection
    connection.Close
    'destroy recordset object
    set Recordset = nothing
    'destroy connection object
    Set connection = Nothing
    %>
    Thanks.
    Attached Thumbnails Attached Thumbnails Errors trying to add data to record-number_integer.jpg  
    Last edited by SteveH; 11-23-2013 at 10:13 AM.


 

Posting Permissions

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