0% found this document useful (0 votes)
9 views

Using Using Using Using Using Using Using Public Class Private Public

The document describes a Windows form application that displays data from a MySQL database in a datagrid. It initializes the datagrid control, sets its properties, and loads data from the Customers table into the datagrid on form load by connecting to the database, running a query, filling a dataset, and setting the dataset as the datagrid's data source.

Uploaded by

Nandha Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Using Using Using Using Using Using Using Public Class Private Public

The document describes a Windows form application that displays data from a MySQL database in a datagrid. It initializes the datagrid control, sets its properties, and loads data from the Customers table into the datagrid on form load by connecting to the database, running a query, filling a dataset, and setting the dataset as the datagrid's data source.

Uploaded by

Nandha Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

using using using using using using using

System; System.Drawing; System.Collections; System.ComponentModel; System.Windows.Forms; System.Data; Microsoft.Data.Odbc;

public class MainClass : System.Windows.Forms.Form { private System.Windows.Forms.DataGrid dataGrid1; public MainClass() { InitializeComponent(); } private void InitializeComponent() { this.dataGrid1 = new System.Windows.Forms.DataGrid(); ((System.ComponentModel.ISupportInitialize) (this.dataGrid1)).BeginInit(); this.SuspendLayout(); // // dataGrid1 // this.dataGrid1.DataMember = ""; this.dataGrid1.HeaderForeColor = System.Drawing.Syste mColors.ControlText; this.dataGrid1.Location = new System.Drawing.Point(0, 8); this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.Size = new System.Drawing.Size(376, 28 8); this.dataGrid1.TabIndex = 0; // // MainClass //

this.AutoScaleBaseSize = new System.Drawing.Size(5, 1 3); this.ClientSize = new System.Drawing.Size(384, 302); this.Controls.AddRange(new System.Windows.Forms.Contr ol[] { this.dataGrid1}); this.Load += new System.EventHandler(this.MainClass_L oad); ((System.ComponentModel.ISupportInitialize) (this.dataGrid1)).EndInit(); this.ResumeLayout(false); } [STAThread] static void Main() { Application.Run(new MainClass()); } private void MainClass_Load(object sender, System.Event Args e) { string connectionString = @"Driver={MySQL};SERVER=loc alhost;DATABASE=NorthwindMySQL;"; OdbcConnection conn= new OdbcConnection(connectionStr ing); conn.Open(); OdbcDataAdapter da = new OdbcDataAdapter ("SELECT Cus tomerID, ContactName, ContactTitle FROM Customers", conn) ; DataSet ds = new DataSet("Cust"); da.Fill(ds, "Customers"); dataGrid1.DataSource = ds.DefaultViewManager;

conn.Close(); } }

You might also like