Hi all plz help i need to search my database using data from the combo box which works fine
the problem that I an experiencing is that FIND function gives me a runtime error, saying the string is not
in the correct format plz help. here is the code that i used.

string data = this.cmbSearch.Items[this.cmbSearch.SelectedIndex].ToString();

                OleDbConnection conn = new OleDbConnection(strCon);
                OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Employee",conn);
                OleDbCommandBuilder oleBuilder = new OleDbCommandBuilder(adapter);
                DataSet ds = new DataSet();
                adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                     
                
                adapter.Fill(ds,"Employee");

                DataRow findrow;
                findrow = ds.Tables["Employee"].Rows.Find(data);
               
                if (findrow == null)
                {
                    MessageBox.Show("Please recheck your spelling", "Employee Not Found",
                       MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    
                }
                else
                {
                    string labeldata = this.cmbSearch.Items[cmbSearch.SelectedIndex].ToString();
                    form2.EmployeeDisplay(data, labeldata);
                    form2.Show();
                    form2.Text = this.cmbSearch.Items[cmbSearch.SelectedIndex].ToString();
                }

>FIND function gives me a runtime error, saying the string is not
in the correct format

Argument of Find method must be primary key column value. I think you are passing string instead of int value.

Thank you very much,it works fine.

Please mark this thread as solved if you have found an answer to your question and good luck!

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.