I can only get entries back from the database if I put a value in the id text field but when I put anything in the other text fields I get no results back when I know for sure that they are in there.
Here is my code:
protected void SearchButton_Click(object sender, EventArgs e)
{
String commandString = "SELECT * FROM [Swim] WHERE (([First Name] LIKE '%' + @First_Name + '%') AND ([Last Name] LIKE '%' + @Last_Name + '%') AND ([Phone] LIKE '%' + @Phone + '%') AND ([id] = @id))";
//SELECT * FROM [Swim] WHERE ([Phone] LIKE '%' + @Phone + '%')
SqlCommand command = new SqlCommand(commandString, conn);
command.Parameters.Add("@First_Name", SqlDbType.NVarChar).Value = FirstNameTextBox.Text;
command.Parameters.Add("@Last_Name", SqlDbType.NVarChar).Value = LastNameTextBox.Text;
command.Parameters.Add("@id", SqlDbType.NVarChar).Value = IdTextBox.Text;
command.Parameters.Add("@phone", SqlDbType.NVarChar).Value = PhoneTextBox.Text;
conn.Open();
command.ExecuteNonQuery();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = command;
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
}
Any suggestions would help?