Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim connection As New SqlConnection("user id=sa;password=sa;initial catalog=tzgl;server=HHH-DP31HPA3Q45")
connection.Open()
Dim sqlstr As String = "select jxmc from jxzk WHERE jxmc LIKE '%'&txtSearchjxzk.text&'%'" Dim command As New SqlCommand(sqlstr, connection)
Dim reader As SqlDataReader = command.ExecuteReader
DataGrid1.DataSource = reader
DataGrid1.DataBind()
reader.Close()
command.Dispose()
connection.Close() End Sub
End Class
Dim connection As New SqlConnection("user id=sa;password=sa;initial catalog=tzgl;server=HHH-DP31HPA3Q45")
connection.Open()
Dim sqlstr As String = "select jxmc from jxzk WHERE jxmc LIKE '%'&txtSearchjxzk.text&'%'" Dim command As New SqlCommand(sqlstr, connection)
Dim reader As SqlDataReader = command.ExecuteReader
DataGrid1.DataSource = reader
DataGrid1.DataBind()
reader.Close()
command.Dispose()
connection.Close() End Sub
End Class
--------------------------------------------------------------------------------列前缀 'txtSearchjxzk' 与查询中所用的表名或别名不匹配。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 列前缀 'txtSearchjxzk' 与查询中所用的表名或别名不匹配。源错误:
行 40:
行 41: Dim command As New SqlCommand(sqlstr, connection)
行 42: Dim reader As SqlDataReader = command.ExecuteReader
行 43: DataGrid1.DataSource = reader
行 44: DataGrid1.DataBind()
源文件: D:\tzgl\webUI\PDMUI\JxnjManage\jxnjtj.aspx.vb 行: 42 堆栈跟踪:
[SqlException: 列前缀 'txtSearchjxzk' 与查询中所用的表名或别名不匹配。]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteReader() +41
PDMUI.jxnjtj.btnSearch_Click(Object sender, EventArgs e) in D:\tzgl\webUI\PDMUI\JxnjManage\jxnjtj.aspx.vb:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
Dim sqlstr As String = "select jxmc from jxzk WHERE jxmc LIKE '%"&txtSearchjxzk.text&"%'";试试。
Dim sqlstr As String = "select jxmc from jxzk WHERE jxmc LIKE '%'&txtSearchjxzk.text&'%'"改成
Dim sqlstr As String = "select jxmc from jxzk WHERE jxmc LIKE '%"+xtSearchjxzk.text+"%'";试试。
Dim connection As New SqlConnection("user id=sa;password=sa;initial catalog=tzgl;server=HHH-DP31HPA3Q45")
connection.Open()
Dim sqlstr As String = "select jxmc from jxzk WHERE jxmc LIKE '%"+txtSearchjxzk.text+"%'" Dim command As New SqlCommand(sqlstr, connection)
Dim reader As SqlDataReader = command.ExecuteReader
DataGrid1.DataSource = reader
DataGrid1.DataBind()
reader.Close()
command.Dispose()
connection.Close() End Sub
End Class
--------------------------------------------------------------------------------当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。源错误:
行 41: Dim reader As SqlDataReader = command.ExecuteReader
行 42: DataGrid1.DataSource = reader
行 43: DataGrid1.DataBind()
行 44: reader.Close()
行 45: command.Dispose()
源文件: D:\tzgl\webUI\PDMUI\JxnjManage\jxnjtj.aspx.vb 行: 43 堆栈跟踪:
[HttpException (0x80004005): 当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。]
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +2066
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +49
System.Web.UI.WebControls.BaseDataList.DataBind() +23
PDMUI.jxnjtj.btnSearch_Click(Object sender, EventArgs e) in D:\tzgl\webUI\PDMUI\JxnjManage\jxnjtj.aspx.vb:43
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------