I'm writing an application that uses ADO.NET OLEDB provider. Database is Access. Most of DB interaction is through DDL/DML SQL queries.
I now need to create linked tables and there doesn't seem to be a way of doing that with ADO.NET alone. Neither in a simple DDL query, nor with trying to manipulate Access system tables directly.
I'm trying to avoid using ADOX, with the extra reference/dependency in my application. Anyone knows a way around this? Much appreciated.
Here's how I currently create linked tables with ADOX.
using ADOX;
public static void CreateLinkedTable(string sourceDB, string sourceTable, string targetDB, string targetTable)
{
Catalog cat = new Catalog();
cat.let_ActiveConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + targetDB);
Table table = new Table();
table.Name = targetTable;
table.let_ParentCatalog(cat);
table.Properties["Jet OLEDB:Create Link"].Value = true;
table.Properties["Jet OLEDB:Link Datasource"].Value = sourceDB;
table.Properties["Jet OLEDB:Remote Table Name"].Value = sourceTable;
cat.Tables.Append(table);
}