I try to add a new column to a sheet using the following code:
try
{
string connection_string = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
@"Data Source=" + file_path + ";" +
@"Extended Properties='Excel 12.0 XML;'";
OleDbConnection ole_db_connection = new OleDbConnection(connection_string);
ole_db_connection.Open();
OleDbCommand cmd = new OleDbCommand("ALTER TABLE [" + sheet_name + "] ADD COLUMN " + column_name + " DOUBLE",
ole_db_connection);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("cannot perform database operation, " + ex.ToString(), "EXCEPTION");
}
The error I get is "System.Data.OleDb.OleDbException (0x80004005)".
User contributions licensed under CC BY-SA 3.0