hey all i have another little issue it's regarding the databinding here and what i'm trying to do here is to get some data from access to my programme how ever the code only work for the first and when i try to invoke it again it give's me the error "This causes two bindings in the collection to bind to the same property."

see the below code :

 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(); 
                    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"); // here where it happened : ERROR : This causes two bindings in the collection to bind to the same property.
                    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");
                }              
            }

So i tried to fix through useing couple of different approch like clearing the datainding of the text box but it dosent seem to work

so any idea's.....???

That's because every time your event (TextChanged) occurs you are calling the "Add" method. You should only add the binding if it doesn't already exist.

well i tried to the biding before the line of the "ADD" but it seems to give me the same error , and what i'm trying to achive is a a select
query from the data base and the result of the query ends up in to the Textbox
so what should i do ???

You may be able to adapt this to use in your program:

How to: Bind Data to the Windows Forms DataGridView Control

The best way for you to learn is to research the issues that you encounter. You will find information that may not be useful to you right now, but one day it may be of use to you. If you are not finding useful information using your favorite search engine, then re-phrase your query--try removing words from your search.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.