开发者

System.InvalidCastException: The conversion is not valid

开发者 https://www.devze.com 2023-02-05 19:17 出处:网络
I get the correct numbers out of the variable(in this case 11) but 开发者_开发问答I cannot compare it because I get this error:

I get the correct numbers out of the variable(in this case 11) but 开发者_开发问答I cannot compare it because I get this error:

System.InvalidCastException: The conversion is not valid

both values are int. I cannot seem to find the problem.

Dim id = CInt(Request.QueryString("id"))
Dim uk = From hj In dc.Orders _
         Where hj.UserID = id _
         Select hj


I'd guess that by just having Dim id that it's getting created as an object, not an integer. Try:

Dim id as Integer
id = CInt(Request.QueryString("id"))

Actually, you should probably be using

Integer.TryParse(Request.QueryString("id"),id)

just in case someone passes in a non-int param.

0

精彩评论

暂无评论...
验证码 换一张
取 消