private void btn_submit_Click(object sender, EventArgs e) { try { string name = textBox1.Text; string filepath="D://"+name; System.Data.OleDb.OleDbConnection MyConnection; System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(); string sql = null; MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filepath+".xls;Extended Properties=Excel 8.0;"); MyConnection.Open(); myCommand.Connection = MyConnection; sql = "Insert into [Sheet1$] (name,email) values('"+textBox1.Text+"','"+textBox2.Text+"')"; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); MyConnection.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)