Posted by : Sudhir Chekuri Saturday, 12 March 2016

//Disconnected - Select
        //Populate the datagridview with registered users information
        public void GetData()
        {
SqlConnection con =new SqlConnection (@"Data Source=DESKTOP-LEBFFH4\PRESS;Initial Catalog=STUDENT;Integrated Security=True");
            //SqlCommand to insert Category
            SqlCommand cmd = new SqlCommand("select * from Tbl_Register", con);
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(ds, "Users");
          
            //Display users table in DataGridView
            DGVUsers.DataSource = ds.Tables["Users"];
        }
//Disconnected - select
        //Populate Products
        public void PopulateProducts()
        {
SqlConnection con =new SqlConnection (@"Data Source=DESKTOP-LEBFFH4\PRESS;Initial Catalog=STUDENT;Integrated Security=True");
            //SqlCommand to get products
            SqlCommand cmd = new SqlCommand("exec Usp_GetProducts '"+CBExistingCategories.Text+"'", con);
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(ds,"Products");
            //Clear existing Products
            CBExistingProducts.Items.Clear();
            //Adding Products to combobox
           
                for(int i=0;i<ds.Tables["Products"].Rows.Count;i++)
                {
                    //Add categories to Combobox
                    CBExistingProducts.Items.Add(ds.Tables["Products"].Rows[i]["ProductName"]);
                }

        }



Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -