0

询问:

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'))

标记:

<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>

错误:

输入字符串的格式不正确.e....

4

1 回答 1

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

将暗示变量@YearFrom@YearTo是字符串,但您将它们声明为 Int32

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

由于字符串 'Year' 不是 int 类型,因此在执行期间将失败。

于 2013-03-14T03:50:47.137 回答