Hi!
I need to rename some MS Access columns name.
I have a table with three columns: name, link in, link out. What I need is to rename link in and link out to link_in and link_out.
In other way it's an update... But I need to learn how it's possible to do it with simple c# code.
Thanx,
Israel.
Loading

IsraelRank #1,223 · 1.5K reputationPosted Feb 4, 2015, 6:37 AM EST
table.Columns.Add("link in", typeof(string));
table.Columns.Add("link out", typeof(string));
VulpesRank #55 · 29.2K reputationPosted Feb 4, 2015, 7:36 AM EST
http://stackoverflow.com/questions/23074935/rename-a-column-in-ms-access-dynamically-using-c-sharp
IsraelRank #1,223 · 1.5K reputationPosted Feb 4, 2015, 10:42 AM EST
I do add this reference Microsoft.office.interop.access.dao. But the bug still on DAO.
// test data
string tableName = "Members";
string oldFieldName = "Photo";
string newFieldName = "Photograph";
// COM Reference required in C# project: // Microsoft DAO 3.6 Object Library //
var dbe = new DAO.DBEngine();
DAO.Database db = dbe.OpenDatabase(@"C:\test\test\\app_data\test.mdb");
DAO.Field fld = db.TableDefs[tableName].Fields[oldFieldName];
fld.Name = newFieldName; db.Close();
VulpesRank #55 · 29.2K reputationPosted Feb 4, 2015, 12:14 PM EST
It doesn't even need a 'using' directive as DAO is a 'top level' namespace.
Are you sure you've added the reference to the Microsoft DAO 3.6 Object Library correctly? It's under the COM tab in the Add Reference dialog.
IsraelRank #1,223 · 1.5K reputationPosted Feb 6, 2015, 2:32 AM EST