0

Query:

SELECT [VehicleId], [VehicleNumber], [VehicleBrand], [VehicleName], [ModelYear], [PurchasePrice]
FROM [VehicleMaster]
WHERE ([VehicleType]=@VehicleType or @VehicleType = '') and 
    ([VehicleNumber]=@VehicleNumber or @VehicleNumber is null) and 
    ([SaleStatus] = @SaleStatus or @SaleStatus = '-Select-') and 
    ([OwnershipStatus]=@OwnershipDetail or @OwnershipDetail = '-Select-')  and
    ([ModelYear] between @YearFrom and @YearTo or (@YearFrom = 'Year' and @YearTo = 'Year'))

Markup:

<SelectParameters>
    <asp:SessionParameter Name="VehicleType" SessionField="VehicleType" Type="String" />
    <asp:SessionParameter Name="VehicleNumber" SessionField="VehicleNumber" Type="String" />
    <asp:SessionParameter Name="SaleStatus" SessionField="SalesStatus" Type="String" />
    <asp:SessionParameter Name="OwnershipDetail" SessionField="OwnershipStatus" Type="String" />
    <asp:SessionParameter Name="YearFrom" SessionField="YearFrom" Type="Int32"  ConvertEmptyStringToNull="true" />
    <asp:SessionParameter Name="YearTo" SessionField="YearTo" Type="Int32" ConvertEmptyStringToNull="true" />
</SelectParameters>

Error:

Input string was not in a correct format.e....

7
  • Please show us your surrounding code.. this is a mess at the moment. Commented Mar 14, 2013 at 3:38
  • "False"> Blockquote? what kind of condition this is? Commented Mar 14, 2013 at 3:39
  • It looks like there are misplaced "blockquote" tags in your server side code... maybe hit the wrong button in the HTML-Format toolbar once? Commented Mar 14, 2013 at 3:41
  • You are declaring @YearFrom and @YearTo to be Int32's but compare them against 'Year' - which isn't a number. - at least I glanced at that in the posted Query that got edited away :) Commented Mar 14, 2013 at 3:44
  • wow.., what happend to the query in the question? Now its parameters?? Commented Mar 14, 2013 at 3:45

1 Answer 1

1
(@YearFrom = 'Year' and @YearTo = 'Year')

would imply that the varaibles @YearFrom and @YearTo are strings, but you declare them as Int32

<asp:SessionParameter Name="YearFrom" SessionField="YearFrom" Type="Int32"  ConvertEmptyStringToNull="true" />
<asp:SessionParameter Name="YearTo" SessionField="YearTo" Type="Int32" ConvertEmptyStringToNull="true" />

Which will fail during execution since the string 'Year' isn't an int type.

Sign up to request clarification or add additional context in comments.

1 Comment

Did you change the 'Year' to something numeric or the Type of the parameter to "String"? It may also mean that the Session Field "Year From" has a non-integer. The Error message indicates that some string parsing went wrong. Hard to tell just about where without the complete stack trace...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.