Hi,

I have developed a windows form application. In this, I created a search history option to search history of records.

The database having these followings fields :

1.Customer Name
2.Project No
3.Date
4.Model Name
5.Type
and some others fields are there.

I created one textBox and two comboBox to get Values from user. And two buttons for search and clear respectively.Following are conditions:

  1. If user enters in those three textboxes , it should display records which contain only those keywords.(i.e. record should statisfies all five keyword)
    2.If user enters only one or two values, it should display values which contain only those keywords(i.e records should statisfies those entered keywords.if any record didn statisfies all entered keywords means it must not been displayed).

i have given code as below:

da=new oledbDataAdapter("Select * from total where Pgma='"+TextBox1.Text+"' or type ='"+combox1.text"' or mname='"+Combobox2.Text+"'",con);

Please provide a solution for my issue on searching techniques.

First, replace your OR with AND. Second you may want to remove a part from the query if that textbox has no value. Third, depending on what/how you want to search, you may want to use a LIKE.

Don't forget the % wild card simbol if you're using like

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.