Here is a google search that gives you instructions on how to achieve this:
If you are creating a WPF application: Data Binding Overview
Based on your connection string I assume that you are working on an ASP.Net application.
You'll probably want to use the databinding features of asp.net.
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Guru\HRP\App_Data\hrp.mdf;Integrated Security=True;User Instance=True");
Here is one article here on CP Mastering ASP.NET DataBinding
] that you may find useful,
This Google search
], provides you with a ton of reading material.
Example from documentation
private static void ReadOrderData(string connectionString)
string queryString =
"SELECT OrderID, CustomerID FROM dbo.Orders;";
using (SqlConnection connection = new SqlConnection(
SqlCommand command = new SqlCommand(
SqlDataReader reader = command.ExecuteReader();
Usually you don't want to reuse the same connection object instance. Create a new SqlConnection on each request.