here i want to enter the result.text box value into excel according to their input.text value. for single value its working fine but i want to insert all the value from result.text to excel.
for example if i enter one folder name in input.tex the n it will retu its path and when i press button2 then it will insert into excel sheet. suppose i have enter multiple folder name in input.text then it will retu path for the all the folder but it won't insert all the path into excel
string [] individualDirs = input.Text.Split(',');
foreach (string one_dir in individualDirs)
{
string[] dirs = Directory.GetDirectories(@"D:", one_dir + "*", SearchOption.AllDirectories);
foreach (string dir in dirs)
{ // to add more Text to your TextBox use +=
Path.Text += dir.ToString() + Environment.NewLine;
}
}
private void button2_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbCoection MyCoection;
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
string sql = null;
MyCoection = new System.Data.OleDb.OleDbCoection(@"provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:consolidated.xls;Extended Properties=Excel 8.0;");
MyCoection.Open();
myCommand.Coection = MyCoection;
sql = "Update [consolidated$] set Path = '"+Path.Text+ " ' where ID='"+input.Text+"' ";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
MyCoection.Close();
}
