I’m working on a catalog program and I use this piece of code to find resources on database:
sql = "SELECT * FROM Articoli WHERE CodiceArt='"+CodArtEntry.Text+"' OR Barcode='"+BarcodeEntry.Text+"' OR NomeArt LIKE '%"+NameArtEntry.Text+"%'";
This code works , but if NameArtEntry (GTK# Entry) is empty, it select every record of the database.
How can I avoid that ? Many thanks
Try this
Using String.Format will make your query more readable, particularly when you write direct sql