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
IsraelPosted Feb 6, 2015, 7:32 AM
VulpesPosted Feb 4, 2015, 5:14 PM
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.
IsraelPosted Feb 4, 2015, 3:42 PM
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();
VulpesPosted Feb 4, 2015, 12:36 PM
http://stackoverflow.com/questions/23074935/rename-a-column-in-ms-access-dynamically-using-c-sharp
IsraelPosted Feb 4, 2015, 11:37 AM
table.Columns.Add("link in", typeof(string));
table.Columns.Add("link out", typeof(string));