J
jerommeke
Hello,
i am a bit confused. I have a OleDb connection to a Microsoft Access
database and I can't seem to programmatically add new columns to the
table. If you look at the example below I try to add a column "ttt" to
a table called "tablename"
When I loop over the rows in the table I can update the existing column
"etc" without a problem, when i check it in the access database
afterwards, it has been succesfully updated. The new column "ttt",
however does only exist in memory. It never gets physically created. Am
I missing something obvious here?
regards
Jeroen van Vlierden (The Netherlands)
string table = "tablename";
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter();
string ssql = "Select * FROM " + table;
adapter.SelectCommand = new OleDbCommand(ssql, myOleDbConnection);
adapter.Fill (ds, table);
ds.Tables
.Columns.Add(new DataColumn("ttt",
typeof(System.Int32)));
foreach( DataRow anyRow in ds.Tables
.Rows)
{
anyRow["Etc" ] = "ttttt"; //this works, because string column etc
already existed in table
anyRow["ttt" ] = 5; // the column exists in memory, this doesnt
generate an exception
}
adapter.Update(ds.Tables
);
i am a bit confused. I have a OleDb connection to a Microsoft Access
database and I can't seem to programmatically add new columns to the
table. If you look at the example below I try to add a column "ttt" to
a table called "tablename"
When I loop over the rows in the table I can update the existing column
"etc" without a problem, when i check it in the access database
afterwards, it has been succesfully updated. The new column "ttt",
however does only exist in memory. It never gets physically created. Am
I missing something obvious here?
regards
Jeroen van Vlierden (The Netherlands)
string table = "tablename";
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter();
string ssql = "Select * FROM " + table;
adapter.SelectCommand = new OleDbCommand(ssql, myOleDbConnection);
adapter.Fill (ds, table);
ds.Tables
typeof(System.Int32)));
foreach( DataRow anyRow in ds.Tables
{
anyRow["Etc" ] = "ttttt"; //this works, because string column etc
already existed in table
anyRow["ttt" ] = 5; // the column exists in memory, this doesnt
generate an exception
}
adapter.Update(ds.Tables