用于搜索文本框
这是我的查询正确查询
Select tip_part_no as TIPPartNo, date_rec as DateRecieve, reciever_name as RecieverName,
qty, SUM(qty) as Total from pcba_info.lot_info where tip_part_no like '' group by
packing_list_no;
我的程序VB中的错误,net T_T
("Select tip_part_no as TIP, SUM(qty) as Total_Quantity from pcba_info.lot_info
WHERE tip_part_no LIKE '%" & Trim(txtsearch.Text.TrimEnd()) & "%' group by
tip_part_no '%" , con)
您应该为此使用参数化查询...
您的查询看起来像这样:
Select tip_part_no as TIPPartNo, date_rec as DateRecieve,
reciever_name as RecieverName, qty, SUM(qty) as Total from pcba_info.lot_info
where tip_part_no like @tip_part_no group by packing_list_no;
然后,您将参数@tip_part_no
与值txtsearch.Text.Trim()
有关在参数化查询中使用类似运算符的信息:带有类似和条件的参数化查询
示例和背景信息在这里:如何创建参数化的SQL查询?我为什么要?
删除%,'(百分比和单引号)符号附近(group by tip_part_no '%"
)
尝试这样的
"Select tip_part_no as TIP, SUM(qty) as Total_Quantity from pcba_info.lot_info
WHERE tip_part_no LIKE '%" & Trim(txtsearch.Text.TrimEnd()) & "%' group by
tip_part_no" , con