shevo

How do I use a parameter query to search for a value based on user input.
E.g. If I enter A in the search box, it will display a list of records based letter starting with A in the datagrid. I am using Microsoft.Jet.OLEDB.4.0.
If i use sql connection, the sql code is
Select Name,Phone from Customer
Where (Name LIKE @Name + '%')
However, I wish to get the same result using data from Microsoft Access.
Hope someone can help.


Re: Windows Forms Data Controls and Databinding parameter query

Ken Tucker

Code Snippet

string strConn = @"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Northwind.mdb;";

string strQuery = "Select * from Products where ProductName Like + '%'";

OleDbConnection conn = new OleDbConnection(strConn);

da = new OleDbDataAdapter(strQuery, conn);

da.SelectCommand.Parameters.AddWithValue("", "ch");

da.Fill(dt);






Re: Windows Forms Data Controls and Databinding parameter query

shevo

Thanks. It works.