public static void WriteXmlSchema (DataSet dataset, XmlWriter writer, DataTableCollection tables, DataRelationCollection relations) { new XmlSchemaWriter (dataset, writer, tables, relations).WriteSchema (); }
public XmlSchemaWriter (DataSet dataset, XmlWriter writer, DataTableCollection tables, DataRelationCollection relations) { ds = dataset; w = writer; this.tables = tables; this.relations = relations; }
private List<DataTable> CreateDataTableList(DataTableCollection dataTableCollection) { List<DataTable> list = new List<DataTable>(); foreach (DataTable dataTable in dataTableCollection) { list.Add(dataTable); } return list; }
public DataSet (string name) { dataSetName = name; tableCollection = new DataTableCollection (this); relationCollection = new DataRelationCollection.DataSetRelationCollection (this); properties = new PropertyCollection (); this.prefix = String.Empty; this.Locale = CultureInfo.CurrentCulture; }
internal bool _udtIsWrapped; // if UDT is wrapped , for YUKON /// <summary> /// Initializes a new instance of the <see cref='System.Data.DataSet'/> class. /// </summary> public DataSet() { GC.SuppressFinalize(this); DataCommonEventSource.Log.Trace("<ds.DataSet.DataSet|API> {0}", ObjectID); // others will call this constr // Set default locale _tableCollection = new DataTableCollection(this); _relationCollection = new DataRelationCollection.DataSetRelationCollection(this); _culture = CultureInfo.CurrentCulture; // Set default locale }
public frmTableEditor(DataTableCollection tables) { InitializeComponent(); Tables = new BindingList<ShineTable>(); foreach(DataTable table in tables) { Tables.Add(new ShineTable(table.TableName)); } lbTables.DataSource = Tables; lbTables.DisplayMember = "TableName"; }
public DataSet() { this.dataSetName = "NewDataSet"; this._datasetPrefix = string.Empty; this.namespaceURI = string.Empty; this.enforceConstraints = true; this.fEnableCascading = true; this.mainTableName = ""; this._defaultViewManagerLock = new object(); this._objectID = Interlocked.Increment(ref _objectTypeCount); GC.SuppressFinalize(this); Bid.Trace("<ds.DataSet.DataSet|API> %d#\n", this.ObjectID); this.tableCollection = new DataTableCollection(this); this.relationCollection = new DataRelationCollection.DataSetRelationCollection(this); this._culture = CultureInfo.CurrentCulture; }
public XmlSchemaWriter (DataSet dataset, XmlWriter writer, DataTableCollection tables, DataRelationCollection relations) { dataSetName = dataset.DataSetName; dataSetNamespace = dataset.Namespace; dataSetLocale = dataset.LocaleSpecified ? dataset.Locale : null; dataSetProperties = dataset.ExtendedProperties; w = writer; if (tables != null) { this.tables = new DataTable[tables.Count]; for(int i=0;i<tables.Count;i++) this.tables[i] = tables[i]; } if (relations != null) { this.relations = new DataRelation[relations.Count]; for(int i=0;i<relations.Count;i++) this.relations[i] = relations[i]; } }
/// <summary> /// Création d'un accès à la base de données et obtention de la liste des tables /// et des contraintes référentielles /// </summary> /// <param name="catalog">Nom de la base</param> public AccèsSQL(string catalog) { // conStr = @"Provider=SQLOLEDB;Data Source=INFO-SIMPLET;Initial Catalog=" + catalog + ";Integrated Security=SSPI"; conStr = @"Provider=SQLOLEDB;Data Source=INFO-SIMPLET;Initial Catalog=" + catalog + ";Uid=ETD;Pwd=ETD"; try { dbCon = new OleDbConnection(conStr); dbCon.Open(); } catch { System.Windows.Forms.MessageBox.Show("Connexion impossible"); return; } if (dbCon.State == ConnectionState.Open) { Collectiontables = GetTables(dbCon); foreignKeys = GetForeignKeys(dbCon); } }
private IList<string> GetTablenames(DataTableCollection tables) { var tableList = new List<string>(); foreach (var table in tables) { tableList.Add(table.ToString()); } return tableList; }
GetObjectData (SerializationInfo info, StreamingContext context) { if (RemotingFormat == SerializationFormat.Xml) { DataSet dset; if (dataSet != null) dset = dataSet; else { dset = new DataSet ("tmpDataSet"); dset.Tables.Add (this); } StringWriter sw = new StringWriter (); XmlTextWriter tw = new XmlTextWriter (sw); tw.Formatting = Formatting.Indented; dset.WriteIndividualTableContent (tw, this, XmlWriteMode.DiffGram); tw.Close (); StringWriter sw2 = new StringWriter (); DataTableCollection tables = new DataTableCollection (dset); tables.Add (this); XmlSchemaWriter.WriteXmlSchema (dset, new XmlTextWriter (sw2), tables, null); sw2.Close (); info.AddValue ("XmlSchema", sw2.ToString(), typeof(string)); info.AddValue ("XmlDiffGram", sw.ToString(), typeof(string)); } else /*if (RemotingFormat == SerializationFormat.Binary)*/ { BinarySerializeProperty (info); if (dataSet == null) { for (int i = 0; i < Columns.Count; i++) { info.AddValue ("DataTable.DataColumn_" + i + ".Expression", Columns[i].Expression); } BinarySerialize (info, "DataTable_0."); } } }
private void WriteTables (XmlWriter writer, XmlWriteMode mode, DataTableCollection tableCollection, DataRowVersion version) { //WriteTable takes care of skipping a table if it has a //Nested Parent Relationship foreach (DataTable table in tableCollection) WriteTable ( writer, table, mode, version); }
public DataSet (string dataSetName) { this.dataSetName = dataSetName; tableCollection = new DataTableCollection (this); relationCollection = new DataRelationCollection.DataSetRelationCollection (this); properties = new PropertyCollection (); prefix = String.Empty; }
internal bool UdtIsWrapped; // if UDT is wrapped , for YUKON /// <devdoc> /// <para>Initializes a new instance of the <see cref='System.Data.DataSet'/> class.</para> /// </devdoc> public DataSet() { GC.SuppressFinalize(this); Bid.Trace("<ds.DataSet.DataSet|API> %d#\n", ObjectID); // others will call this constr // Set default locale this.tableCollection = new DataTableCollection(this); this.relationCollection = new DataRelationCollection.DataSetRelationCollection(this); _culture = CultureInfo.CurrentCulture; // Set default locale }
private long saveResponseForm(DataTableCollection tables) { Lib.Entities.ResponseForm form = new Lib.Entities.ResponseForm(); form.Answers = new List<Lib.Entities.Answer>(); form.UserId = int.Parse(ddlEntidades.SelectedValue); form.CityId = int.Parse(hdnCityId.Value); Lib.Entities.Answer resposta = null; foreach (DataTable table in tables) { foreach (DataRow row in table.Rows) { resposta = new Lib.Entities.Answer(); resposta.BaseQuestionId = long.Parse(row.ItemArray[5].ToString()); resposta.Observation = row.ItemArray[3].ToString(); decimal score = 0; if (decimal.TryParse(row.ItemArray[2].ToString(), NumberStyles.Any, new System.Globalization.CultureInfo("en-US"), out score)) { resposta.Score = score; } form.BaseFormId = long.Parse(row.ItemArray[6].ToString()); form.Answers.Add(resposta); resposta = null; } } using (Lib.Repositories.ResponseFormRepository rep = new Lib.Repositories.ResponseFormRepository(this.ActiveUser)) { rep.save(form); } return form.Id; }
private void WriteTables (XmlWriter writer, XmlWriteMode mode, DataTableCollection tableCollection, DataRowVersion version) { //Write out each table in order, providing it is not //part of another table structure via a nested parent relationship foreach (DataTable table in tableCollection) { bool isTopLevel = true; /* foreach (DataRelation rel in table.ParentRelations) { if (rel.Nested) { isTopLevel = false; break; } } */ if (isTopLevel) { WriteTable ( writer, table, mode, version); } } }
/// <summary> /// This member is only meant to support Mono's infrastructure /// </summary> void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) { DataSet dset; if (dataSet != null) dset = dataSet; else { dset = new DataSet ("tmpDataSet"); dset.Tables.Add (this); } StringWriter sw = new StringWriter (); XmlTextWriter tw = new XmlTextWriter (sw); tw.Formatting = Formatting.Indented; dset.WriteIndividualTableContent (tw, this, XmlWriteMode.DiffGram); tw.Close (); StringWriter sw2 = new StringWriter (); DataTableCollection tables = new DataTableCollection (dset); tables.Add (this); XmlSchemaWriter.WriteXmlSchema (dset, new XmlTextWriter (sw2), tables, null); sw2.Close (); info.AddValue ("XmlSchema", sw2.ToString(), typeof(string)); info.AddValue ("XmlDiffGram", sw.ToString(), typeof(string)); }
public void WriteXmlSchema (XmlWriter writer) { DataSet ds = DataSet; DataSet tmp = null; try { if (ds == null) { tmp = ds = new DataSet (); ds.Tables.Add (this); } DataTableCollection col = new DataTableCollection (ds); col.Add (this); XmlSchemaWriter.WriteXmlSchema (ds, writer, col, null); } finally { if (tmp != null) ds.Tables.Remove (this); } }
// Function : ExportData // Arguments : table, FormatType, FileName // Purpose : To get all the column headers in the datatable and // exorts in CSV / Excel format with all columns public void ExportData(DataTableCollection tables, ExportFormat FormatType, string FileName) { try { string NewFileName; if (tables == null) throw new Exception("There are no details to export."); foreach(DataTable DetailsTable in tables) { if(DetailsTable.Rows.Count == 0) throw new Exception("There are no details to export."); NewFileName = FileName.Substring(0,FileName.LastIndexOf(".")); NewFileName+= " - " + DetailsTable.TableName; NewFileName+= FileName.Substring(FileName.LastIndexOf(".")); // Create Dataset DataSet dsExport = new DataSet("Export"); DataTable dtExport = DetailsTable.Copy(); dtExport.TableName = "Values"; dsExport.Tables.Add(dtExport); // Getting Field Names string[] sHeaders = new string[dtExport.Columns.Count]; string[] sFileds = new string[dtExport.Columns.Count]; for (int i=0; i < dtExport.Columns.Count; i++) { sHeaders[i] = dtExport.Columns[i].ColumnName; sFileds[i] = dtExport.Columns[i].ColumnName; } if(appType == "Web") Export_with_XSLT_Web(dsExport, sHeaders, sFileds, FormatType, NewFileName); else if(appType == "Win") Export_with_XSLT_Windows(dsExport, sHeaders, sFileds, FormatType, NewFileName); } } catch(Exception Ex) { throw Ex; } }
/// <summary> /// 打印 DataTableCollection . /// </summary> /// <param name="sb">输出缓冲区.</param> /// <param name="indent">缩进.</param> /// <param name="obj">对象.</param> public static void PrintDataTableCollection(StringBuilder sb, int indent, DataTableCollection obj) { int indentnext = indent + 1; String indentstr = GetIndentStr(indent); sb.AppendLine(string.Format("{0}# <{1}>", indentstr, obj.GetType().FullName)); sb.AppendLine(string.Format("{0}# Count:\t{1}", indentstr, obj.Count)); int i = 0; foreach (DataTable p in obj) { sb.AppendLine(string.Format("{0}[{1}]:\t{2}", indentstr, i, p)); PrintDataTable(sb, indentnext, p); ++i; } }
protected bool canShowSubmitButton(DataTableCollection tables, out List<string> notAnsweredQuestions, out List<string> incorrectAnsweredQuestions) { notAnsweredQuestions = new List<string>(); incorrectAnsweredQuestions = new List<string>(); List<String> AcceptedAnswers = new List<string>(); AcceptedAnswers.Add("n/a"); AcceptedAnswers.Add("0"); AcceptedAnswers.Add("0.5"); AcceptedAnswers.Add("0,5"); AcceptedAnswers.Add("1"); AcceptedAnswers.Add("1.0"); AcceptedAnswers.Add("1,0"); foreach (DataTable table in tables) { foreach (DataRow row in table.Rows) { if (row[4].ToString() == "P") { if (String.IsNullOrEmpty(row[2].ToString())) { notAnsweredQuestions.Add(row[0] + " - " + row[1]); } else { if (!AcceptedAnswers.Contains(row[2].ToString())) { incorrectAnsweredQuestions.Add(row[0] + " - " + row[1]); } } } } } if (notAnsweredQuestions.Count > 0 || incorrectAnsweredQuestions.Count > 0) { return false; } return true; }
// ExtendedProperties private bool CheckExtendedPropertyExists ( DataTableCollection tables, DataRelationCollection relations) { if (ds.ExtendedProperties.Count > 0) return true; foreach (DataTable dt in tables) { if (dt.ExtendedProperties.Count > 0) return true; foreach (DataColumn col in dt.Columns) if (col.ExtendedProperties.Count > 0) return true; foreach (Constraint c in dt.Constraints) if (c.ExtendedProperties.Count > 0) return true; } if (relations == null) return false; foreach (DataRelation rel in relations) if (rel.ExtendedProperties.Count > 0) return true; return false; }
private string ToStringInternal(DataTableCollection tables) { StringBuilder text = new StringBuilder(); foreach (DataTable table in tables) { if (text.Length > 0) { text.Append(", "); } text.Append(table.TableName); } return text.ToString(); }
private void YhdistaTietokanta(string polku) { if (!File.Exists(polku)) { MessageBox.Show("Tietokantaa ei löytynyt, käytä selausta", "Virhe", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Settings.Default["Polku"] = polku; Settings.Default.Save(); AccessHandler.SuljeYhteys(); AccessHandler.Yhdista(polku); AccessHandler.ViestienNaytto(Ulkoiset: Ulkoiset, Sisaiset: Sisaiset); taulut = AccessHandler.EtsiTaulut(); taulut.Remove("Lukkari"); DTC = AccessHandler.HaeTaulut(taulut); AccessHandler.TaulunTiedot(DTC); SQLRakentaja.DTC = DTC; sarakkeet = new List<string>(); sarakkeet.Add("Nimi"); sarakkeet.Add("Periodi"); sarakkeet.Add("Viikko"); sarakkeet.Add("Paiva"); sarakkeet.Add("Alkaa"); sarakkeet.Add("Loppuu"); sarakkeet.Add("Sali"); sarakkeet.Add("Huom"); data = new List<string>(); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); data.Add("VARCHAR(255)"); if (taulut.Count > 0) TeePuu(); var cult = CultureInfo.CurrentCulture; var weekNo = cult.Calendar.GetWeekOfYear( System.DateTime.Now, cult.DateTimeFormat.CalendarWeekRule, cult.DateTimeFormat.FirstDayOfWeek); LabelViikko.Text = "Viikko " + weekNo; TeeLukujarjestysDT(); }