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.
Dinusha GamagePosted May 23, 2008, 7:20 AM
Bechir BejaouiPosted May 23, 2008, 5:55 AM
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();
}