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 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts

    13 TypeMismatchError

    when i execute following two procedure from UI it will give a error that is
    ERROR:13 Type Mismatch.

    when i execute same statements at SQL server by passing same values as passed by UI.It will successfully executed but when i passed the values from UI it will give 13 type mismatch ERROR.Please give me solution



    sql = "EXEC ALLFEE_ADDTRANSACTIONS '"&rForm("strDescription")&"',0,"&intTotalPaidAmount&",'"&rForm("strBusDescription")&"',0,"&intTotal BusAmount&",'"&rForm("strExamFeeDescription")&"',0,"&intTotalExamFeePaidAmount&","&cint(session("DID "))&",'"&getLocalDateTime()&"'," & intReceiptId & ",6"
    conn.execute (sql)

    If rForm("floatDiscount") <> "" Or rForm("floatBusDiscount") <> "" Or Trim(rForm("floatExamFeeDiscount")) <> "" then
    sql = ""
    sql = "EXEC ALLMAINTAINANCE_ADDEXPENSES 1,'"&getLocalDateTime()&"',"& intDiscount &",'"&strStudnetCode&" - Term Fee Discount',"&intBusDiscount&",'"&strStudnetCode&" - Bus Fee Discount',"& intExamFeeDiscount &",'"&strStudnetCode&" - Exam Fee Discount',"&cint(session("DID"))&",7"
    conn.execute (sql)
    End If

  • #2
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Let's use the code tags.
    Formatting can also help identify simple errors.

    I removed a few spaces that might have been created by you or because you posted it using the wrong tags in the forum.

    Code:
    strDescription = rForm("strDescription")
    strBusDescription = rForm("strBusDescription")
    strExamFeeDescription = rForm("strExamFeeDescription")
    intDID = cint(session("DID"))
    
    sql = "EXEC ALLFEE_ADDTRANSACTIONS '" & strDescription & "', 0, " & intTotalPaidAmount & ", '" & _
                                         strBusDescription & "', 0, " & intTotalBusAmount & ", '" & _
                                     strExamFeeDescription & "', 0, " & intTotalExamFeePaidAmount & ", " & _
                                                    intDID & ", '" & getLocalDateTime() & "', " & _
                                              intReceiptId & ", 6;"
    conn.execute (sql)
    
    If rForm("floatDiscount") <> "" Or rForm("floatBusDiscount") <> "" Or Trim(rForm("floatExamFeeDiscount")) <> "" then
      sql = "EXEC ALLMAINTAINANCE_ADDEXPENSES 1, '" & getLocalDateTime() & "', " & _
                                                             intDiscount & ", '" & strStudnetCode & " - Term Fee Discount', " & _
                                                          intBusDiscount & ", '" & strStudnetCode & " - Bus Fee Discount', " & _
                                                      intExamFeeDiscount & ", '" & strStudnetCode & " - Exam Fee Discount', " & _
                                                                  intDID & ", 7;"
      conn.execute (sql)
    End If
    I am not sure what your problem is, but if you trouble shoot your variables you might get your answer. Find out their datatypes too, that might be the issue.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    You are beating a dead horse.

    The error has nothing to do with the SQL.

    His problem is that he is using ON ERROR RESUME NEXT and getting an error *SOMEWHERE* in his code but then he doesn't *discover* the error until he executes the stored proc at which point he then looks for an Err.Number. He *thinks* the error is because of the EXEC, but in actuality it happened who knows how many lines before.

    See the other thread with the same subject.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    I didn't realize it was a double post until after I formatted the code.

    Now it's just an example of how to format your code for better readability.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    Most anything would help that mess he has, wouldn't it?

    That's an interesting coding style. My own preference would be more for something like:
    Code:
    Function SQLString(val)
         SQLString = "'" & Replace(val,"'","''") & "'"
    End Function
    Function SQLNumber(val)
         SQLNumber = CString(CDBL(val)) ' to ensure it *IS* a number
    End Function
    
    sql = "EXEC ALLFEE_ADDTRANSACTIONS " _
        &     SQLString(strDescription) _
        & ",0" _
        & "," & SQLNumber(intTotalPaidAmount) _
        & "," & SQLString(strBusDescription) _
        & ",0" _
        & "," & SQLNumber(intTotalBusAmount) _
        & "," & SQLString(strExamFeeDescription) _
        & ",0" _
        & "," & SQLNumber(intTotalExamFeePaidAmount) _
        & "," & SQLNumber(intDID) _
        & ",'" & getLocalDateTime() & "'" _
        & "," & SQLNumber(intReceiptId) _
        & ",6;"
    Even for inhouse projects, I'd like to be SURE that my values don't cause SQL errors and/or don't allow SQL Injection attacks.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Morgoth (07-09-2012)

  • #6
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Even better.


  •  

    Posting Permissions

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