Quantcast
Viewing latest article 1
Browse Latest Browse All 2

How to use DataGrid in C# .Net?

First place the DataGridView Control in the form.In the coding add the namespasce

using System.Data.SqlClient;

then initialize SqlConnection to ConnString as public (i.e)next to public Form1( ) {InitializeComponent( );}

SqlConnection con = new SqlConnection(“Your Connection String”);

DataSet ds;

Inside any event such as Form_load or button1_click add the code

SqlDataAdapter da=new SqlDataAdapter(“select * from table1″,con);

ds=new DataSet();

da.Fill(ds,”table1″);

dataGridView1.DataSource=ds;

dataGridView1.DataMember=”table1″;

By

Udhaya


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 1
Browse Latest Browse All 2

Trending Articles