用户代码未处理 System.Data.SqlClient.SqlException 列名 '%线%' 无效。
ImportsSystemImportsSystem.Collections.GenericImportsSystem.LinqImportsSystem.WebImpo...
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.SqlClient
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
GridView1.Visible = True
Label1.Visible = False
Dim cxt As String
Dim cxnr As String
cxnr = TextBox1.Text
Select Case DropDownList1.Text
Case "名称"
cxt = "名称"
Case "类型"
cxt = "类型"
Case "地点"
cxt = "存放地点"
Case "具体位置"
cxt = "具体位置"
End Select
If DropDownList1.Text <> "查询全部数据" Then
If cxnr = "" Then
MsgBox("请输入查询条件!")
Else
Dim conn As SqlConnection = New SqlConnection(connster)
conn.Open()
Dim sqlstr As String = "SELECT * FROM haocai WHERE " + cxt + " LIKE " + Chr(34) + "%" + cxnr + "%" + Chr(34)
Dim cmd As SqlCommand = New SqlCommand(sqlstr, conn)
If (cmd.ExecuteScalar <> Nothing) Then
Dim dr As SqlDataReader = cmd.ExecuteReader()
GridView1.DataSource = dr
GridView1.DataBind()
dr.Close()
Else
GridView1.Visible = False
Label1.Visible = True
End If
End If 展开
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.SqlClient
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
GridView1.Visible = True
Label1.Visible = False
Dim cxt As String
Dim cxnr As String
cxnr = TextBox1.Text
Select Case DropDownList1.Text
Case "名称"
cxt = "名称"
Case "类型"
cxt = "类型"
Case "地点"
cxt = "存放地点"
Case "具体位置"
cxt = "具体位置"
End Select
If DropDownList1.Text <> "查询全部数据" Then
If cxnr = "" Then
MsgBox("请输入查询条件!")
Else
Dim conn As SqlConnection = New SqlConnection(connster)
conn.Open()
Dim sqlstr As String = "SELECT * FROM haocai WHERE " + cxt + " LIKE " + Chr(34) + "%" + cxnr + "%" + Chr(34)
Dim cmd As SqlCommand = New SqlCommand(sqlstr, conn)
If (cmd.ExecuteScalar <> Nothing) Then
Dim dr As SqlDataReader = cmd.ExecuteReader()
GridView1.DataSource = dr
GridView1.DataBind()
dr.Close()
Else
GridView1.Visible = False
Label1.Visible = True
End If
End If 展开
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询