开发者

System.InvalidCastException: The conversion is not valid

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜