My code is:
This shows me an error in else part MySQL Query.How to solve it.
I have error on sql syntax.
My error is:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''%'' at line 1
dbConnection()
Using cmd As New MySqlCommand
If String.IsNullOrEmpty((formPOS.productSearchTB.Text.Trim())) Then
sql = "SELECT Product_ID, Product_ID_Barcode, Name, Price, Category, Price_Code, Name_of_Supplier, Delivery_Date, Unit, Quantity FROM products_database;"
ElseIf Not String.IsNullOrEmpty((formPOS.productSearchTB.Text.Trim())) Then
sql = "SELECT Product_ID, Product_ID_Barcode, Name, Price, Category, Price_Code, Name_of_Supplier, Delivery_Date, Unit, Quantity FROM products_database Where Name LIKE @p1'%';"
cmd.Parameters.AddWithValue("@p1", formPOS.productSearchTB.Text.Trim())
End If
cmd.CommandText = sql
cmd.Connection = conn
dt = New DataTable
da = New MySqlDataAdapter
Dim bsource As New BindingSource
da.SelectCommand = cmd
da.Fill(dt)
bsource.DataSource = dt
formPOS.PriceListDGV.DataSource = dt
End Using
Please help