void addRelation(string refName, string mainTable, string subTable, string mainField, string subField) { DatabaseTable mTbl = FindTable(mainTable); DatabaseTable sbTbl = FindTable(subTable); if (mTbl != null && sbTbl != null) { EPField mFld = mTbl.FindField(mainField); EPField subFld = sbTbl.FindField(subField); if (Relations == null) { Relations = new TableRelations(); } Relations.AddJoinFields(refName, mainTable, subTable, mFld, subFld); } }
public void LoadTables() { Tables = null; Relations = null; if (dbCon.TheConnection is OdbcConnection) { Tables = dbCon.ODBC_GetTables(); } else { System.Data.DataTable schema = dbCon.GetTables(); if (schema == null) { return; } if (schema.Rows.Count > 0) { System.Data.DataRow row = null; int n; string s; int nCount = 0; DatabaseTable[] Tables0 = new DatabaseTable[schema.Rows.Count]; for (n = 0; n < schema.Rows.Count; n++) { row = schema.Rows[n]; s = row["Table_type"].ToString(); if (string.Compare(s, "TABLE", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(s, "BASE TABLE", StringComparison.OrdinalIgnoreCase) == 0) { Tables0[nCount] = new DatabaseTable(); Tables0[nCount].TableName = row["Table_Name"].ToString(); nCount++; } } Tables = new DatabaseTable[nCount]; for (n = 0; n < nCount; n++) { Tables[n] = Tables0[n]; } } } }
public void LoadRelations() { int i; Relations = new TableRelations(); string refName, mainTable, subTable, mainField, subField; System.Data.DataTable schemaRelation = dbCon.GetRelations(); if (schemaRelation == null) { return; } for (i = 0; i < schemaRelation.Rows.Count; i++) { mainTable = schemaRelation.Rows[i]["PK_TABLE_NAME"].ToString(); subTable = schemaRelation.Rows[i]["FK_TABLE_NAME"].ToString(); mainField = schemaRelation.Rows[i]["PK_COLUMN_NAME"].ToString(); subField = schemaRelation.Rows[i]["FK_COLUMN_NAME"].ToString(); refName = schemaRelation.Rows[i]["FK_NAME"].ToString(); addRelation(refName, mainTable, subTable, mainField, subField); } }