using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.SqlClient; public class LiaisonTableCommandes : System.Windows.Forms.Form { private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Data.DataSet dataSet1; private System.ComponentModel.Container components = null; public LiaisonTableCommandes() { InitializeComponent(); } private void InitializeComponent() { this.listBox1 = new System.Windows.Forms.ListBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.dataSet1 = new System.Data.DataSet(); ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit(); this.SuspendLayout(); this.listBox1.Location = new System.Drawing.Point(8, 8); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(232, 95); this.listBox1.TabIndex = 0; this.textBox1.Location = new System.Drawing.Point(8, 120); this.textBox1.Name = "textBox1"; this.textBox1.TabIndex = 1; this.textBox1.Text = "textBox1"; this.textBox2.Location = new System.Drawing.Point(8, 152); this.textBox2.Name = "textBox2"; this.textBox2.TabIndex = 2; this.textBox2.Text = "textBox2"; this.dataSet1.DataSetName = "NewDataSet"; this.dataSet1.Locale = new System.Globalization.CultureInfo("en-US"); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(256, 188); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.listBox1); this.Name = "LiaisonTableCommandes"; this.Text = "Les Données de la table Clients"; this.Load += new System.EventHandler(this.LiaisonTableCommandes_Load); ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit(); this.ResumeLayout(false); } static void Main() { Application.Run(new LiaisonTableCommandes()); } private void LiaisonTableCommandes_Load(object sender, System.EventArgs e) { string chianeConnexion = "server=(local);database=MesExemples.com;Integrated Security=SSPI"; string requete = "select * from Clients"; SqlConnection conn = new SqlConnection(chianeConnexion); SqlDataAdapter da = new SqlDataAdapter(requete, conn); da.Fill(dataSet1, "Clients"); DataTable dt = dataSet1.Tables["Clients"]; listBox1.DataSource = dt; listBox1.DisplayMember = "ID"; textBox1.DataBindings.Add("text", dt, "Société"); textBox2.DataBindings.Add("text", dt, "Activites"); } } |
0