I am doing a uni project where I need to search for a user from a database in Visual Studio 2010, based on their FirstName, SurName, EmailAddress or SkillSet using a SQL command in vb.net.
So from the start... The use registers and includes a skill set that is a single textbox that they type in the likes of "Java", "C#", etc.
I can search for the everything fine, apart from the SkillSet if the user has more than one skill.
I want to search for anything using "LIKE" in the SQL command.
Here's what I have at the minute for searching for a user:
SQL command to select the details I want
Dim command As New SqlCommand("SELECT [FirstName], [SurName], [EmailAddress], [SkillSet], [UserID] FROM [Users] WHERE ([FirstName] = @FirstName OR [SurName] = @SurName OR [EmailAddress] = @EmailAddress OR [SkillSet] LIKE '%' @SkillSet '%')", connection)
Creating the Paramaters
Dim firstnameParam As New SqlParameter("@FirstName", Me.UserSearchTextBox.Text)
Dim surnameParam As New SqlParameter("@SurName", Me.UserSearchTextBox.Text)
Dim emailParam As New SqlParameter("@EmailAddress", Me.UserSearchTextBox.Text)
Dim skillSetParam As New SqlParameter("@SkillSet", Me.UserSearchTextBox.Text)
command.Parameters.Add(firstnameParam)
command.Parameters.Add(surnameParam)
command.Parameters.Add(emailParam)
command.Parameters.Add(skillSetParam)`