Wednesday, May 2, 2007

How to populate DataGridView, GridView with SQL statement in C# - The Code Project - ASP.NET

How to populate DataGridView, GridView with SQL statement in C# - The Code Project - ASP.NET: "How to populate DataGridView, GridView with SQL statement in C#"

protected void Page_Load(object sender, EventArgs e)
{

string strSQLconnection = "Data Source=dbServer;Initial Catalog=testDB;Integrated Security=True";
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from table1", sqlConnection);
sqlConnection.Open();

SqlDataReader reader = sqlCommand.ExecuteReader();

GridView1.DataSource = reader;
GridView1.DataBind();
}

http://www.svdeals.com/ super value deals

No comments: