Hi Guys
My code below search for a record in excel based on a textbox text and bind it to a datagrid. but if I tried searching for the same value and bind it again I got error " DataBinding cannot find a row in the list that is suitable for all bindings." any idea how to reset the binding ? I tries formattingEnables set to true it didn't work. thank you
OleDbConnection connExcel = new OleDbConnection(_econnect);
cmdExcel.Connection = connExcel;
connExcel.Open();
DataTable dt;
DataSet ds = new DataSet();
dt = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
OleDbDataAdapter da = new OleDbDataAdapter();
string sheetname = "BadgeID$";
cmdExcel.CommandText = "select ID, Name, Dept from [" + sheetname + "] where ID in (" + sss +")";
da.SelectCommand = cmdExcel;
da.Fill(ds);
connExcel.Close();
bsdata .DataSource = ds.Tables [0]; //error here
Invoke(new MethodInvoker(() => textBox1.DataBindings.Add("Text", bsdata, "Name")));
Invoke(new MethodInvoker(() => textBox2.DataBindings.Add("Text", bsdata, "Dept")));