datagrids

Aug 22 2006 10:28 AM
I am brand new to C#.net develper.

I have a windows form with a
data grid on it. I am getting the data from an Oracle Database. I am able to display the data from the database on the data grid when a button is clicked. But what I need to do is enter 3 items (company, cons number, and year) into 3 text boxes and then when the button is clicked I only want to pull the data from the database where the company, cons number, and year match what was entered into the text boxes. Any help would be wonderful!!!!

I added a rowfilter but is there a way to have it look at a text box to get the filter data?

public bool fnGetDataConnection()
{
try
{
con =new OleDbConnection(conString);
dAdapter=new OleDbDataAdapter("select * from forecast_exec_dir", con);
dSet=new DataSet();
//refreshes rows in the DataSet
dAdapter.Fill(dSet,"forecast_exec_dir");
}
catch(Exception ex)
{
MessageBox.Show("Error : "+ex.Message);
//connectection failed
return false;
} //try-catch
//connection ok!
return true;
}


private void btFind_Click(object sender,
System.EventArgs e)
{
if (this.fnGetDataConnection())
{
this.dataGrid1.ReadOnly=true;
{
thisdataGrid1.DataSource=dSet.Tables["forecast_exec_dir"];
dSet.Tables["forecast_exec_dir"].DefaultView.RowFilter="company = this.txtComp";
fnGetDataBindingForTextBoxes();
fnSetCurrencyManager();
fnDisplayRecordNumbers();
}
}
else
{
MessageBox.Show("Connection failed...");
Application.Exit();
}
}