problem changing Access column default value
I am having a problem changing the default value
for a column with C# code. The simplest way to
do it seems to be to use oleDbDataAdapter1.Fill(dt),
even though I don't actually want to query for
any data in the database? I just want a handle
to the table so I can change one of its columns
default value.
In VS, I setup a oleDbConnection1 using the
Server Explorer/Data Connections.
I just set it up with any old SQL connection
string, I'm not interested in the dataset:
this.oleDbSelectCommand1.CommandText = "SELECT *\r\nFROM table1";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
Then, I wrote the following code:
DataTable dt = new DataTable();
oleDbDataAdapter1.Fill(dt);
dt.Columns["color"].DefaultValue = "green";
oleDbDataAdapter1.Update(dt);
oleDbConnection1.Close();
This code doesn't work.
I'm looking at the generated code in the designer and
it makes me think that to change the default value for
a column, I should be using
System.Data.OleDb.OleDbParameter
or
oleDbDataAdapter1.TableMappings?
Any help would be appreciated.
|