public void GetFields(Connection cnt) { System.Data.DataTable schemaColumn; fields = new FieldList(); Indexes = null; // //===================================================== dbWrapper db = new dbWrapper(); db.CreateCommand((Connection)cnt.Clone()); EPField fld; if (cnt.IsOleDb) { db.SetCommandText(TableName); db.SetCommandType(System.Data.CommandType.TableDirect); } else { db.SetCommandText("SELECT * FROM " + DatabaseEditUtil.SepBegin(cnt.NameDelimiterStyle) + TableName + DatabaseEditUtil.SepEnd(cnt.NameDelimiterStyle)); db.SetCommandType(System.Data.CommandType.Text); } try { if (cnt.IsOleDb || cnt.IsMSSQL) { db.OpenReader(System.Data.CommandBehavior.KeyInfo); } else { db.OpenReader(System.Data.CommandBehavior.SchemaOnly); } schemaColumn = db.GetSchemaTable(); db.CloseReader(); db.Close(); if (schemaColumn != null) { for (int i = 0; i < schemaColumn.Rows.Count; i++) { fld = EPField.MakeFieldFromColumnInfo(i, schemaColumn.Rows[i]); if (!string.IsNullOrEmpty(fld.Name)) { fld.FromTableName = TableName; fields.AddField(fld); } } } } catch (Exception er) { FormLog.NotifyException(true, er); } finally { db.CloseReader(); db.Close(); } }
public void GetFields(Connection cnt) { int i; System.Data.DataTable schemaColumn = null; fields = new FieldList(); if (cnt.IsOdbc) { return; } //===================================================== EPField fld; dbWrapper db = new dbWrapper(); db.CreateCommand(cnt); string sep1 = DatabaseEditUtil.SepBegin(cnt.NameDelimiterStyle); string sep2 = DatabaseEditUtil.SepEnd(cnt.NameDelimiterStyle); db.SetCommandText("SELECT * FROM " + sep1 + ViewName + sep2); db.SetCommandType(System.Data.CommandType.Text); try { db.OpenReader(System.Data.CommandBehavior.SchemaOnly); schemaColumn = db.GetSchemaTable(); db.CloseReader(); db.Close(); if (schemaColumn != null) { for (i = 0; i < schemaColumn.Rows.Count; i++) { fld = EPField.MakeFieldFromColumnInfo(i, schemaColumn.Rows[i]); fld.FromTableName = ViewName; fields.AddField(fld); } } } catch { } finally { db.CloseReader(); db.Close(); } }