Esempio n. 1
0
        private void FrmInStock_Load(object sender, EventArgs e)
        {
            //SqlConnection con = new SqlConnection("Server=D8JZPCQ2;Database=dbPhoneShop;User ID=sa;Password=123");
            //con.Open();
            ConectionString con = new ConectionString();

            con.SetConnection();
            //Add date to combobox
            try
            {
                string     sql = "Select * from tbProduct Order By ProductID";
                SqlCommand cmd = new SqlCommand("spRunSQL", con.con);
                cmd.Parameters.AddWithValue("@sql", sql);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader dr = cmd.ExecuteReader();
                DataTable     tb = new DataTable();
                tb.Load(dr);
                dgvProduct.DataSource = tb;

                // con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }