Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2014

    Question Unanswered: Error when c# calls my stored procedure.

    I have a stored procedure with this code in an ELSE IF block. When my c# code calls it, it returns an error of "Conversion failed when converting the varchar value '1007 Single Family FHA' to datatype tinyint."

    The varchar value is stored in the P.ProductName column and table.

    Any idea what is causing this error?

    SELECT COUNT(*) FROM @updateTable AS UT
                         INNER JOIN tSpecialPricingSheetPrice AS SPSP ON (SPSP.SpecialPricingSheetPriceKey = UT.SpecialPricingSheetPriceKey)
                         LEFT OUTER JOIN tState AS S ON (SPSP.StateID = S.StateID)
                         LEFT OUTER JOIN tCounty AS C ON (SPSP.CountyKey = C.CountyKey)
                         LEFT OUTER JOIN tProduct AS P ON (SPSP.ProductKey = P.ProductKey)
                         WHERE ISNULL(UT.RegionNumber, 0) <> ISNULL(SPSP.RegionNumber, 0) AND
                               ISNULL(S.StateName, '(' + C.StateID + ') ' + C.CountyName) <> UT.StateCounty AND
                               ISNULL(SPSP.ProductGroupNumber, 0) <> ISNULL(UT.Product, 0) AND
                               ISNULL(P.ProductName, '') <> ISNULL(UT.Product, '')
                  ) > 0

  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    what's the data type of UT.Product? sometime you isNull it to a character and sometimes a zero? I would bet your issue is there.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jul 2014


    Aha! It wasn't that, it was an issue with the 3rd part of the WHERE clause. I accidentally called SPSP.ProductGroupNumber (which is a tinyint) against UT.Product (which is a varchar)! Should have called against UT.ProductGroupNumber!

    Your response did get me thinking though!

Tags for this Thread

Posting Permissions

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