Skip to content

What is the search method in C# instead of Find method in VB 6?

Dinusha Gamage

Asked May 22, 2008, 10:17 PM EDT2 answers
Share
LinkedInX

Dear Friends,

I need a help from all of you. That is, I need to write a search method to search data once you click on the Search button. Ok I'll explain the senario as below.

Assume that once you click on the Search button it will be dropped down the code list from a combo box in the form. Then, once you select the perticular code from the dropped down list, and the combo box will hide and another text box appear there diplaying the code that you have already selected from the combo box. At the same time it should search for the perticular recordset from the table in the DB and display data in the form. Ex. If you select Code, then it will be able to find the description for that and display both Code and description in the form.

Hope you will guide me.

Tnx.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    First of all witch kind of data base do you use.
    you should use  ado.net to achieve this task. Assume that we need a record from an access data base C:\myDB.mdb
    using System.Data;
    using System.Data.Oledb;

    OleDbCommand comm;
    OlsDbDataReader  Reader;
    OleDbConnection conn = new
    OleDbConnection(@"Provider = Microsoft.Jet.OLEDB.4.0; Data Source="C:\myDB.mdb;");
    conn.Open()
    comm = new OleDbCommand("Select ....", conn);
    try
    {
       Reader = comm.ExecuteReader();
       try
           {
                While(Reader.Read())
                 ListBox.Items.Add(Reader["Your field name"/or File index 0 based]);
           }
           Finally{Reader.close();}
    }
    Finally
    {
       conn.Close();
    }
    0
  • 1 short reply