Example #1
0
        private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataSet personDataSet = new DataSet();

            personDataSet            = Handlers.RetrieveSQLData(personDataSet, DataStrings.SqlConnectionString(), DataStrings.DGVMainFormDataQuery());
            dgvPersonInfo.DataSource = personDataSet.Tables["Person"];

            //forces columns in dgvPersonInfo to fill
            for (int i = 0; i < 6; i++)
            {
                dgvPersonInfo.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
            MessageBox.Show("Data refreshed.", "Person Information", MessageBoxButtons.OK);
        }
Example #2
0
        //on load do this.
        private void Main_Load(object sender, EventArgs e)
        {
            try
            {
                //using SelectRows method to grab data safely.
                DataSet personDataSet = new DataSet();
                personDataSet            = Handlers.RetrieveSQLData(personDataSet, DataStrings.SqlConnectionString(), DataStrings.DGVMainFormDataQuery());
                dgvPersonInfo.DataSource = personDataSet.Tables["Person"];

                //forces columns in dgvPersonInfo to fill
                for (int i = 0; i < 6; i++)
                {
                    dgvPersonInfo.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
                dgvPersonInfo.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
                //Debug tool
                //MessageBox.Show("Connection successful.");
            }
            catch
            {
                //duh
                MessageBox.Show("Connection to database failed.");
            }
        }