System Object[ Displaying all entities and their records ]

 System Object-

System Object represents all entities in the data base. 


Objective- We have to code inside the Show Entities button such that all entities inside the database will be shown in the List Box below.

And By selecting one of the entities the user can also see the records inside the table by clicking on Show records button.

Show Entities button code-

{

string cn = ConfigurationManager.AppSettings["key"];

cn = new SqlConnection(cs);

cn.Open(); 

string q = "select name from sysobjects where xtype='U' order by name";

cm = new SqlCommand(q,cn);

dr = cm.ExecuteReader();

ListBox1.DataSource = dr;

ListBox1.DataTextField = "name";

ListBox1.DataBind(); 

dr.Close();

Show Records Code- 

{  

string cn = ConfigurationManager.AppSettings["key"];

cn = new SqlConnection(cs);

cn.Open();  

string q = "select * from" + " " + ListBox1.Text;

cm = new SqlCommand(q,cn); 

dr = cm.ExecuteReader; 

GridView1.DataSource = dr;

GridView1.DataBind();

dr.Close();

}

Comments

Popular posts from this blog

Parameter Query

Final Project

Grid View Paging