Home > Code > ASP.NET > Creating a database connection, data adapter, data set and display the data from the data set using ...

Creating a database connection, data adapter, data set and display the data from the data set using ADO.NET

by Narain Siddharth   on Jan 16, 2011   Category: ASP.NET   |  Views: 1011    |  Points: 25   |  Silver 



   //Database Connection
SqlConnection objConn = new SqlConnection("server=(local);database=TestDB;Trusted_Connection=yes");
// Data adapter creation.
SqlDataAdapter objAdEmp = new SqlDataAdapter("select * from employees", objConn);
// Data set creation.
DataSet objdsEmp = new DataSet();
// Filling the data set object.
objAdEmp.Fill(objdsEmp, "Employees");
// Display the data with datagrid.
DataGrid1.DataSource = objdsEmp.Tables["Employees"].DefaultView;
DataGrid1.DataBind();




Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts