private void linkFirstTable(ref string source) { ADOX.Catalog cat = default(ADOX.Catalog); ADOX.Table tbl = default(ADOX.Table); Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); // ERROR: Not supported in C#: OnErrorStatement if (fso.FileExists(modRecordSet.serverPath + source + ".mdb")) { } else { return; } cat = new ADOX.Catalog(); short x = 0; // Open the catalog. cat.let_ActiveConnection(modReport.cnnDBreport); for (x = cat.Tables.Count - 1; x >= 0; x += -1) { switch (Strings.LCase(cat.Tables(x).name)) { case "adayendstockitemlnk": cat.Tables.delete(cat.Tables(x).name); break; } } tbl = new ADOX.Table(); tbl.name = "aDayEndStockItemLnk"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "DayEndStockItemLnk"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); cat.Tables.Refresh(); cat = null; return; withPass: openConnection_linkFirstTable: //cat.ActiveConnection("Jet OLEDB:Database Password") = "lqd" //Resume Next //Exit Sub //If Err.Description = "[Microsoft][ODBC Microsoft Access Driver] Not a valid password." Then // GoTo withPass //ElseIf Err.Description = "Not a valid password." Then // GoTo withPass //Else Interaction.MsgBox(Err().Number + " - " + Err().Description); //End If }
private void linkTables(ref string source) { ADOX.Catalog cat = default(ADOX.Catalog); ADOX.Table tbl = default(ADOX.Table); Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); if (fso.FileExists(modRecordSet.serverPath + source + ".mdb")) { } else { return; } cat = new ADOX.Catalog(); short x = 0; // Open the catalog. cat.let_ActiveConnection(modReport.cnnDBreport); for (x = cat.Tables.Count - 1; x >= 0; x += -1) { switch (Strings.LCase(cat.Tables(x).name)) { case "acustomertransaction": case "adayendstockitemlnk": case "adeclaration": case "asale": case "asaleitem": case "asuppliertransaction": cat.Tables.delete(cat.Tables(x).name); break; } } tbl = new ADOX.Table(); tbl.name = "aCustomerTransaction"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "CustomerTransaction"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); tbl = new ADOX.Table(); tbl.name = "aDayEndStockItemLnk"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "DayEndStockItemLnk"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); tbl = new ADOX.Table(); tbl.name = "aDeclaration"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "Declaration"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); tbl = new ADOX.Table(); tbl.name = "aSale"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "Sale"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); tbl = new ADOX.Table(); tbl.name = "aSaleItem"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "SaleItem"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); tbl = new ADOX.Table(); tbl.name = "aSupplierTransaction"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = modRecordSet.serverPath + source + ".mdb"; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "SupplierTransaction"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); cat.Tables.Refresh(); cat = null; }
private static void linkFirstTable(ref string Source) { ADOX.Catalog cat = default(ADOX.Catalog); ADOX.Table tbl = default(ADOX.Table); Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); if (fso.FileExists(strLocation)) { } else { return; } cat = new ADOX.Catalog(); short x = 0; //Open the catalog. //MsgBox StrLocRep cat.let_ActiveConnection(modReport.cnnDBConsReport); for (x = cat.Tables.Count - 1; x >= 0; x += -1) { switch (Strings.LCase(cat.Tables(x).Name)) { case "adayendstockitemlnk": cat.Tables.delete(cat.Tables(x).Name); break; } } tbl = new ADOX.Table(); tbl.Name = "aDayEndStockItemLnk"; tbl.ParentCatalog = cat; tbl.Properties("Jet OLEDB:Link Datasource").Value = strLocation; tbl.Properties("Jet OLEDB:Remote Table Name").Value = "DayEndStockItemLnk"; tbl.Properties("Jet OLEDB:Create Link").Value = true; cat.Tables.Append(tbl); cat.Tables.Refresh(); cat = null; }