Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello expert ,

In my project admin has created the page and content is saved in the database
, i have shown the data according to the data saved in the format
or i have just have to populate the data in the page

any example will be appreciated (web based application )


any suggestion ...
Posted
Comments
[no name] 28-Jun-13 6:11am    
Sounds like a question you need to ask your project admin. We would have no idea what you project requirements are.
Shafeequl 28-Jun-13 6:24am    
what you need?? need to take the data from db table to datatable??

1 solution

You have to retrieve data in DataTable or DataSet

e.g.

C#
try{



               SqlConnection con = new SqlConnection("");//connection name

               con.Open();

               SqlCommand cmd = new SqlCommand("select * from tablename", con);

               cmd.CommandType = CommandType.Text;

               SqlDataAdapter da = new SqlDataAdapter(cmd);

               DataSet ds = new DataSet();

               da.Fill(ds, "ss");

//You can use DataSet yo Bind Grid in this way.

               dataGridView1.DataSource = ds.Tables["ss"]; 

              dataGridView1.DataBind();

//Else you can use also for other controls like

      TextBox1.Text=ds.Tables["ss"].Rows[0]["ColumnName"].toString();
      Label1.Text=ds.Tables["ss"].Rows[0]["ColumnName"].toString();



            }

            catch

            {

              MessageBox.Show("No Record Found");

            }
 
Share this answer
 
Comments
vivek_2984 28-Jun-13 8:07am    
Hi
Thanks for the reply ...
I have to just fetch the data from database ... I am saving the whole information in the database ..?? does this will work
Nirav Prabtani 28-Jun-13 8:40am    
sure this will work dear,,:)
vivek_2984 29-Jun-13 2:33am    
Yes it work for me ... now I trying to create a method so i can use it all the page
Nirav Prabtani 29-Jun-13 4:50am    
great..:)
Nirav Prabtani 29-Jun-13 4:51am    
if it is working then mark it as solved..:)

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