hi all;
again i have a little bit wired problem here
what i'm trying to achive here is that i would like to to a search query to search an employee and after that change the depatment and after that update the data into access database and as you can see in the below pic
i'm using the search query in the text changed event in the text box to search for the employee after after that i'm using te following code to refile the combobox
AValue, string Adisplay)
{
string Value = AValue;
string display = Adisplay;
using (var CBConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\AMS.mdb;"))
{
CBConn.Open();
DataTable CbDt = new DataTable();
try
{
OleDbCommand CBCmd = new OleDbCommand(Query, CBConn);
OleDbDataReader CBReader = CBCmd.ExecuteReader();
CbDt.Load(CBReader);
}
catch (OleDbException e)
{
MessageBox.Show(e.ToString());
return;
}
DropDownName.DataSource = CbDt;
DropDownName.ValueMember = Value;
DropDownName.DisplayMember = display;
}
}
and after that i pass thefollowing to the methode here
FillDropDownList("SELECT empcode,empname from Deparment WHERE TypeCode = '" + emp.Text + "'", TypeEmp_CB, "empcode", "empname");
and i tried recalling it one more time by using it in a different to refill the combobox with all the deparments so that the user will be able to select a different deparment like the below
FillDropDownList("SELECT empcode,empname from Deparment ", TypeEmp_CB, "empcode", "empname");
how ever scine all of that is running during the text changed event it the text is refilled but the selected item is the fisrt item just in the table not the correct deparment of the employee so anby ideas