Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one table data.I have inserted data into one table like employee table.Now when i click on insert button ,it will insert data.But after that i want to show the updated table data in next asp page.as I am new to .net please provide me simple code so that i can eaisly understand.I want to print the table data in a page ,while it is loading itself(in the page load i want to write the code of it).Please provide simple solution.
Posted

1 solution

using select Query....
protected void Page_Load(object sender, EventArgs e)
{

SqlConnection con=new Sqlconnection("Data Source=.\\sqlexpress;Initial Catalog=DatabaseName;Integrated Security=True");
SqlCommand cmd=new SqlCommand("Select * from employee",con);
SqlDataReader dr=cmd.ExecuteReader()'
While(dr.Read())
{
TextBox1.Text=dr.GetValue(0).ToString();//first value of a employee table
TextBox2.Text=dr.GetValue(1).ToString();//second value of a employee table
TextBox3.Text=dr.GetValue(2).ToString();//third value of a employee table
.
.
.
}
}
Try This Code....
 
Share this answer
 
v2
Comments
vinod.sambangi 20-Nov-12 3:58am    
It was saying error in this line, "While(dr.Read())" as While does not exist in the current context
vinod.sambangi 20-Nov-12 4:15am    
Please tell me
sarathtamil 21-Nov-12 23:17pm    
while(dr.Read())//while is lower case letter..........
sarathtamil 21-Nov-12 23:17pm    
while is small letter....

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