// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Drawing; using System.Windows.Forms; using System.Data; using System.Data.OleDb; using System.Xml; namespace E { public class MainForm : Form { private Button button1; private TextBox textBox1; private TextBox textBox2; public MainForm() { InitializeComponent(); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } private void InitializeComponent() { textBox1 = new TextBox(); textBox2 = new TextBox(); button1 = new Button(); SuspendLayout(); textBox1.Location = new Point(25, 25); textBox1.Size = new Size(150, 25); textBox2.Location = new Point(25, 75); textBox2.Size = new Size(150, 25); button1.Location = new Point(25, 125); button1.Size = new Size(150, 25); button1.Text = "Hent MAX og MIN"; button1.Click += new System.EventHandler(Button1Click); ClientSize = new Size(200, 200); Controls.Add(button1); Controls.Add(textBox2); Controls.Add(textBox1); Text = "MainForm"; ResumeLayout(false); } void Button1Click(object sender, System.EventArgs e) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\MSAccess\Test.mdb"); con.Open(); OleDbDataAdapter da = new OleDbDataAdapter("(SELECT MIN(F1) FROM T1) UNION (SELECT MAX(F1) FROM T1)", con); DataSet ds = new DataSet("T1Summary"); da.Fill(ds, "record"); String xml = ds.GetXml(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList nodes = doc.SelectNodes("T1Summary/record/Expr1000"); textBox1.Text = nodes.Item(0).FirstChild.Value; textBox2.Text = nodes.Item(1).FirstChild.Value; } } }