here my code which need to save data from excel sheet to database access using C#. I don't get any error but my excel data could not be updated in database access.. What I have to do for this?
My Database Access Tablename is "addsales1".
My Excel sheet name is "addsales1".
string file_name = Application.StartupPath + "\\" + "databaseset.txt";
System.IO.StreamReader objreader;
objreader = new System.IO.StreamReader(file_name);
string sh = objreader.ReadLine();
string con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + textBox9.Text
+ ";Extended Properties=Excel 8.0;";
OleDbConnection connection = new OleDbConnection(con);
OleDbCommand cmd = new OleDbCommand("INSERT INTO [MS Access;Database=" + sh +
"].[addsales1] SELECT * FROM [addsales1$]");
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
MessageBox.Show("Sales Details Imported Successfully!");