private void ReadOleDbDataConnection(XmlNode node, StiReport report) { StiOleDbDatabase database = new StiOleDbDatabase(); report.Dictionary.Databases.Add(database); database.Name = ReadString(node, "Name", database.Name); foreach (XmlNode elementNode in node.ChildNodes) { switch (elementNode.Name) { case "TableDataSource": ReadTableDataSource(elementNode, report, database.Name); break; } } }
private void button3_Click(object sender, EventArgs e) { bool IsNameUnique = true; string connectionString1 = textBox1.Text.Trim(); string connectionString2 = textBox2.Text.Trim(); if ((connectionString1.Length > 0) || (connectionString2.Length > 0)) { if (this.Report == null) { this.Report = new StiReport(); } this.Report.Dictionary.Clear(); this.report.DataStore.Clear(); } if (connectionString1.Length > 0) { StiDatabase mySqlDatabase = null; foreach (StiDatabase database in this.report.Dictionary.Databases) { if (database.Name == "MyStiSqlDatabase") { mySqlDatabase = database; } } if (mySqlDatabase == null) { mySqlDatabase = new StiSqlDatabase("MyStiSqlDatabase", connectionString1); this.Report.Dictionary.Databases.Add(mySqlDatabase); } if (mySqlDatabase.GetType() == typeof(StiSqlDatabase)) { foreach (string myItem in checkedListBox1.CheckedItems) { IsNameUnique = true; foreach (StiDataSource source in this.Report.DataSources) { if (source.Name == myItem) { IsNameUnique = false; } } if (IsNameUnique) { StiSqlSource sqlSource = new StiSqlSource("MyStiSqlDatabase", myItem, myItem, "SELECT * FROM dbo.\"" + myItem + "\""); this.Report.Dictionary.DataSources.Add(sqlSource); this.Report.Dictionary.Synchronize(); sqlSource.SynchronizeColumns(); } } } } if (connectionString2.Length > 0) { StiDatabase myOleDbDatabase = null; foreach (StiDatabase database in this.report.Dictionary.Databases) { if (database.Name == "MyStiOleDbDatabase") { myOleDbDatabase = database; } } if (myOleDbDatabase == null) { myOleDbDatabase = new StiOleDbDatabase("MyStiOleDbDatabase", connectionString2); this.Report.Dictionary.Databases.Add(myOleDbDatabase); } if (myOleDbDatabase.GetType() == typeof(StiOleDbDatabase)) { foreach (string myItem in checkedListBox2.CheckedItems) { IsNameUnique = true; foreach (StiDataSource source in this.Report.DataSources) { if (source.Name == myItem) { IsNameUnique = false; } } if (IsNameUnique) { StiOleDbSource oleDbSource = new StiOleDbSource("MyStiOleDbDatabase", myItem, myItem, "SELECT * FROM [" + myItem + "]"); this.Report.Dictionary.DataSources.Add(oleDbSource); this.Report.Dictionary.Synchronize(); oleDbSource.SynchronizeColumns(); } } } } if (this.Report == null) { this.Report = new StiReport(); } if (this.Report.Designer == null) { StiDesigner.CreatedReport += new EventHandler(StiDesigner_CreatedReport); StiDesigner.ClosingDesigner += ClosingDesigner; MessageBox.Show("Click 'File' then 'New Report' and this dialog appears again."); this.Report.Design(); this.Report = null; } else { this.Close(); } }