Change path linked table ms access

Asked

Viewed 803 times

1

  • 1

    You can run this VBA as a macro in Access and call this macro by C#

  • Thanks man, but I got by the c#

1 answer

1


// the following code requires that the project have a COM reference to:
// "Microsoft Office 14.0 Access Database Engine Object Library"

// create the DBEngine object
var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngine();

// open the local database file containing the linked table
Microsoft.Office.Interop.Access.Dao.Database db = dbe.OpenDatabase(fileNamePainelGerencialTo);

// create a TableDef object for the linked table we want to update
Microsoft.Office.Interop.Access.Dao.TableDef tbd = db.TableDefs["tblPendencia"];

// update the .Connect property with the full path to the remote database
tbd.Connect = ";DATABASE=" + fileNamePainelGerencialPendenciasTo;

// refresh the table link
tbd.RefreshLink();

// create a TableDef object for the linked table we want to update
tbd = db.TableDefs["tblPendenciaBaixa"];

// update the .Connect property with the full path to the remote database
tbd.Connect = ";DATABASE=" + fileNamePainelGerencialPendenciasTo;

// refresh the table link
tbd.RefreshLink();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.