查询:
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>
错误:
输入字符串的格式不正确。..... ....
答案 0 :(得分: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" />
由于字符串&#39; Year&#39;不是int类型。