c# Using Parameters.AddWithValue in SqlDataAdapter

The string used to initialize the SqlDataAdapter becomes the CommandText of the SelectCommand property of the SqlDataAdapter. You could add parameters to that command with this code da = new SqlDataAdapter(“SELECT * FROM annotations WHERE annotation LIKE @search”, _mssqlCon.connection); da.SelectCommand.Parameters.AddWithValue(“@search”,”%” + txtSearch.Text + “%”); First, remove the single quote around the parameter placeholder. Second, add … Read more