Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2012, 07:08 PM   PM User | #1
prashanth193
New Coder

 
Join Date: Dec 2011
Posts: 29
Thanks: 6
Thanked 0 Times in 0 Posts
prashanth193 is an unknown quantity at this point
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
prashanth193 is offline   Reply With Quote
Old 07-07-2012, 10:39 PM   PM User | #2
Morgoth
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
Morgoth is an unknown quantity at this point
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.
Morgoth is offline   Reply With Quote
Old 07-08-2012, 07:57 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 07-08-2012, 03:19 PM   PM User | #4
Morgoth
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
Morgoth is an unknown quantity at this point
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.
Morgoth is offline   Reply With Quote
Old 07-08-2012, 10:15 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
Morgoth (07-08-2012)
Old 07-08-2012, 11:42 PM   PM User | #6
Morgoth
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
Morgoth is an unknown quantity at this point
Even better.
Morgoth is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:47 AM.


Advertisement
Log in to turn off these ads.