G
Guest
I'm trying to convert a procedure from an old VB6 app that creates an access
linked table and am having syntax problems with setting the properties. The
code is listed below. Anyone have ideas on how to do this?
private static void CreateLinkedExternalTable(string strTargetDB, string
strProviderString, string strSourceTbl, string strLinkTblName)
{
ADOX.CatalogClass catDB = new ADOX.CatalogClass();
ADOX.Table tblLink = new ADOX.Table();
// Open a Catalog on the database in which to create the link.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ strTargetDB;
//Name the new Table and set its ParentCatalog property to the open
Catalog to allow access to the Properties collection.
tblLink.Name = strLinkTblName;
tblLink.ParentCatalog = catDB;
// Set the properties to create the link.
tblLink.Properties("Jet OLEDB:Create Link") = true;
tblLink.Properties("Jet OLEDB:Link Provider String") = strProviderString;
tblLink.Properties("Jet OLEDB:Remote Table Name") = strSourceTbl;
// Append the table to the Tables collection.
catDB.Tables.Append(tblLink);
catDB = null;
}
linked table and am having syntax problems with setting the properties. The
code is listed below. Anyone have ideas on how to do this?
private static void CreateLinkedExternalTable(string strTargetDB, string
strProviderString, string strSourceTbl, string strLinkTblName)
{
ADOX.CatalogClass catDB = new ADOX.CatalogClass();
ADOX.Table tblLink = new ADOX.Table();
// Open a Catalog on the database in which to create the link.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ strTargetDB;
//Name the new Table and set its ParentCatalog property to the open
Catalog to allow access to the Properties collection.
tblLink.Name = strLinkTblName;
tblLink.ParentCatalog = catDB;
// Set the properties to create the link.
tblLink.Properties("Jet OLEDB:Create Link") = true;
tblLink.Properties("Jet OLEDB:Link Provider String") = strProviderString;
tblLink.Properties("Jet OLEDB:Remote Table Name") = strSourceTbl;
// Append the table to the Tables collection.
catDB.Tables.Append(tblLink);
catDB = null;
}