public DataTable GetConnectionObjects(eDBObjectType objectType) { DataTable objSchemaTable = null; string strobjectType = ""; switch (objectType) { case eDBObjectType.Table: { strobjectType = "TABLE"; break; } case eDBObjectType.View: { strobjectType = "VIEW"; break; } } try { if (mobjOLEConnection == null) { mobjOLEConnection = GetOLEConnection(mstrADOConnectionString); } mobjOLEConnection.Open(); switch (objectType) { case eDBObjectType.Procedure: { objSchemaTable = mobjOLEConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Procedures, new object[] { null, null, null, null }); break; } default: { objSchemaTable = mobjOLEConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, strobjectType }); break; } } mobjOLEConnection.Close(); } catch (Exception ex) { // Don//t throw, a test of objSchemaTable = null is made by caller Console.WriteLine(ex.ToString()); } finally { if (mobjOLEConnection.State != ConnectionState.Closed) { mobjOLEConnection.Close(); } } return objSchemaTable; }
public DataTable GetConnectionObjects(string businessClass, eDBObjectType objectType, string[] includedSPs) { DataTable objSchemaTable = null; string strobjectType = ""; switch (objectType) { case eDBObjectType.Table: { strobjectType = "TABLE"; break; } case eDBObjectType.View: { strobjectType = "VIEW"; break; } } try { if (mobjOLEConnection == null) { mobjOLEConnection = GetOLEConnection(mstrADOConnectionString); } mobjOLEConnection.Open(); switch (objectType) { case eDBObjectType.Procedure: objSchemaTable = mobjOLEConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Procedures, new object[] { null, null, null, null }); break; default: objSchemaTable = mobjOLEConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, strobjectType }); break; } mobjOLEConnection.Close(); } catch (Exception ex) { // Don//t throw, a test of objSchemaTable = null is made by caller Console.WriteLine(ex.ToString()); } finally { if (mobjOLEConnection.State != ConnectionState.Closed) { mobjOLEConnection.Close(); } } /* if (businessClass != "") { objSchemaTable = FilterObjectsByClass(objSchemaTable, businessClass); if (includedSPs != null) { objSchemaTable = FilterObjectsBySelection(objSchemaTable, includedSPs); } } */ return objSchemaTable; }