FYI - How to rename an MS access table

E

Ed Eichman

Hi Guys,

I just figured out how to rename an MSAccess table, and thought I'd
post the info. Basic idea scrounged from
http://www.4guysfromrolla.com/webtech/tips/t030802-1.shtml and
http://www.codeguru.com/vb_database/CreateMSAccess.html

ADODB.Connection adodbConn = new ADODB.Connection ();
adodbConn.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
strFileName, "", "", 0);
ADOX.Catalog db = new ADOX.Catalog ();
db.ActiveConnection = adodbConn;
foreach (ADOX.Table tbl in db.Tables) {
if (tbl.Name == "tableToRename") {
tblToRename = "newTableName";
break;
}
}

HTH,
Ed Eichman
Rocinante Software S.L. (www dot rocinantesoftware dot com)
Cambrils, Spain
 
E

Ed Eichman

Addendum:

You also have to add references to the correct DLLs, and make sure you
include MDAC in your installer. MDAC 2.8 has a release manifest so
that you can see which DLLs the user will have installed. For earlier
versions, check to see what versions of the DLLs get installed.

To add references, right click your project n the solution explorer,
and select "add reference...". In the COM tab, select
Microsoft ADO Ext. for DDL and Security
Microsoft ActiveX Data Objects Library

Versions depend on the version of MDAC you rely on.

If you have a web-deploy project for your project (and possibly other
type of deploy project), you will get an error during build about the
dlls in question not being overwritable (or something to that effect).
Just exclude the dlls from your deploy project, and you're set.

HTH,
Ed Eichman
Rocinante Software S.L. (www.rocinantesoftware.com)
Cambrils, Spain
 
Top