1

For Search textbox

this is my query correct query

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;

error in my program 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)
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143

2 Answers2

2

You should use a parameterised query for this...

Your query then looks like this:

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;

Then you add the parameter @tip_part_no with the value txtsearch.Text.Trim()

Information about using LIKE operator in parameterized queries: Parameterized Queries with LIKE and IN conditions

Example and background information here: How do I create a parameterized SQL query? Why Should I?

Community
  • 1
  • 1
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
0

Remove %,' (Percentage and Single quotes) symbols near Group By (group by tip_part_no '%")

Try like this

"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
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115