Saturday, August 11, 2018

Display all table in listbox


    
Display all  table in listbox 

protected void Button4_Click(object sender, EventArgs e)
    {

        //R&D  DATABASE

        string cs1 = ConfigurationManager.AppSettings["mydatabase"];
        cn7 = new SqlConnection(cs1);
        cn7.Open();

        string k = "SELECT name FROM sysobjects WHERE xtype='U' ORDER BY name";
        cm7 = new SqlCommand(k, cn7);
        dr7 = cm7.ExecuteReader();
        ListBox1.DataSource = dr7;
        ListBox1.DataTextField = "name";
        ListBox1.DataBind();
        ListBox1.Items.Insert(0, "Select");
    }






    protected void Button6_Click(object sender, EventArgs e)
    {
        //RND FIND
        string cs1 = ConfigurationManager.AppSettings["mydatabase"];
        cn7 = new SqlConnection(cs1);
        cn7.Open();

        string k = "select * from" + " " + ListBox1.Text;
        cm7 = new SqlCommand(k, cn7);
        dr7 = cm7.ExecuteReader();

        GridView1.DataSource = dr7;
        GridView1.DataBind();
    }

No comments:

Post a Comment

GRIDVIEW ON ROW DATA BOUND EVENT

 Database Create  Student : roll , name , city , cost  Fix 6 Value  in Database Record  ====================================================...