how to put value in parameters in mysqldataadapter 1

how to put value in parameters in mysqldataadapter

da = new SqlDataAdapter("SELECT * FROM annotations WHERE annotation LIKE @search",
                        _mssqlCon.connection);
da.SelectCommand.Parameters.AddWithValue("@search","%" + txtSearch.Text + "%");

Here is what the above code is Doing:
1. Create a new SqlDataAdapter object.
2. Set the SelectCommand property of the SqlDataAdapter object to a new SqlCommand object.
3. Set the CommandText property of the SqlCommand object to the SQL query.
4. Set the Connection property of the SqlCommand object to the SqlConnection object.
5. Add a parameter to the SqlCommand object.
6. Set the value of the parameter to the value of the textbox.
7. Fill the DataTable object with the results of the query.
8. Set the DataSource property of the DataGridView object to the DataTable object.

Similar Posts