hey all,
i have a little issue here with the below however the wired thing that i encoutred is that the below code run only for one time perfectly and when i invoked it again it displayes the error : " The ConnectionString property has not been initialized. "
private void Label1_TextChanged(object sender, EventArgs e)
{
// the below Snippet is for Searching the database Access and Retirving it in the database
if (Label2.Text == "EDIT")
{
using (AMSCONN)
{
string UpdateString = "SELECT EmpCode,EfCode,Branch,SectorName,EmpType,SuperVisor,EmpName,Govenment,District,Area,Email,addrs FROM AddressBook WHERE EmpCode = '" + ForSearch.Text + "'";
}
AMSCONN.Open(); // here is where the error happen but it only happen's when the code is invoked for the second time
MessageBox.Show(ex.Message);
OleDbCommand UpdateCMD = new OleDbCommand(UpdateString, AMSCONN);
OleDbDataAdapter UpdateAD = new OleDbDataAdapter(UpdateCMD);
DataTable UpdateTable = new DataTable();
UpdateAD.Fill(UpdateTable);
AMSCONN.Close();
EmpTxt.DataBindings.Add("Text", UpdateTable, "EmpCode"); // retriving the enp code that it is used in the app
Sector_CB.DataBindings.Add("Text", UpdateTable, "SectorName");
FillDropDownList("SELECT SecCode,SecName FROM Sectors WHERE SecCode = " + Sector_CB.Text +"", Sector_CB, "SecCode", "SecName");
Name_Txt.DataBindings.Add("Text", UpdateTable, "EmpName");
Branch_CB.DataBindings.Add("Text", UpdateTable, "Branch");
}
}
i really tried to close the connection and disposing it after running the code but it dosen't seem to work ,,,, so can any one here help me