private void Init_schemaTable_dic() { if (this.schemaTable_dic != null) { return; } this.schemaTable_dic = new Dictionary <string, HashSet <string> >(StringComparer.OrdinalIgnoreCase); DB_select selt = new DB_select(TableSchema.Get_cmdTP()); DB_reader reader = null; try { reader = new DB_reader(selt, this); } catch (Exception ex) { Console.WriteLine("hssDB error 1: " + ex.ToString()); return; } while (reader.Read()) { TableSchema ts = new TableSchema(); ts.Init_from_reader(reader); if (!this.schemaTable_dic.ContainsKey(ts.TABLE_SCHEMA)) { HashSet <string> table_hs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); this.schemaTable_dic[ts.TABLE_SCHEMA] = table_hs; } this.schemaTable_dic[ts.TABLE_SCHEMA].Add(ts.TABLE_NAME); } reader.Close(); }
public DB_reader(DB_select selt, hssDB hDB) { if (hDB == null || !hDB.Connected) { return; } if (selt == null) { return; } selt.DBname = hDB.DBname; this.db_sel = selt; SqlCommand cmd = selt.GetSQL_cmd(); cmd.Connection = hDB.DB_connection; cmd.CommandTimeout = hssDB.CommandTimeout; this.reader = cmd.ExecuteReader(); }
/// <summary> /// Initialize object from DB /// </summary> public bool Init_from_DB() { if (this.DTCModelMappingID < 0) { return(false); } HssUtility.SQLserver.DB_select db_sel = new HssUtility.SQLserver.DB_select(DTCPositionModelNumber_Mapping.Get_cmdTP()); db_sel.tableName = "DTCPositionModelNumber_Mapping"; HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("DTCModelMappingID", HssUtility.General.RelationalOperator.Equals, this.DTCModelMappingID); db_sel.SetCondition(rela); bool res_flag = false; HssUtility.SQLserver.DB_reader reader = new HssUtility.SQLserver.DB_reader(db_sel, Utility.Get_DRWIN_hDB()); if (reader.Read()) { this.Init_from_reader(reader); res_flag = true; } reader.Close(); return(res_flag); }