I\'m having a problem with my code:
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Your website is in serious danger of being hacked.
Read up on SQL Injection and how to prevent it in .NET
Your query problem is the least of your concerns right now.
But.....
@Misnomer's solution is close but not quite there:
Change your query to this:
cmd.CommandText = "SELECT * FROM borrow where (Department LIKE '%@DepartmentText%')"
and add parameters this way (or the way that @Misnomer does):
cmd.Parameters.AddWithValue("@DepartmentText",TextBox2.Text)
The important difference is that you need to change your CommandText.