asp.net ID进行查询

来源:百度知道 编辑:UC知道 时间:2024/06/04 02:30:47
以下是代码
Dim titleid As Integer = Convert.ToInt32(Request.QueryString("id"))
Dim strsql As String = "select * from [guestbook] where [guestbook_id] = '" + titleid + "'"
但运行的时候出错
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 27: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Line 28: Dim titleid As Integer = Convert.ToInt32(Request.QueryString("id"))
Line 29: Dim strsql As String = "select * from [guestbook] where [guestbook_id] = '" + titleid + "'"
Line 30: D

问的问题太不专业了... 回答不了 。。

Dim strsql As String = "select * from [guestbook] where [guestbook_id] = " + titleid + ""

改成这样。

你的guestbook_id是整数类型吧?整数类型,等号后边不需要加单引号

'" + titleid + "'

去掉单引号.

..Input string was not in a correct format.