Click here to Skip to main content
15,936,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Sir I want to stored data into database and show this Data on my web page. Firstly I am stored data into database (Sql Server 2005)which i done.But I have some problem to retrieving data on webpage. Can u help me.


Thanks.
Posted

You could start with some tutorials on DB access here[^].
 
Share this answer
 
void BindGridView()
{ SqlConnection con = new SqlConnection("server=WASIF\\SQLEXPRESS;database=HRMS;integrated security=true");

SqlCommand cmd = new SqlCommand("select * from abc", con);
con.Open();
SqlDataReader dtr = cmd.ExecuteReader();
if (dtr.Read())
{
GridView1.DataSource = dtr;
GridView1.DataBind();
dtr.Close();
con.Close();
}
}
On page Load Event call this function as
if (!IsPostBack)
{
BindGridView();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900