UserInsert ui = new UserInsert();
ui.ShowDialog();
//ui.DialogResult
if (ui.DialogResult == DialogResult.OK)
{
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Test;Integrated Security=True");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select id,name from users", conn);
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
this.dataGridView1.DataSource = dt;
}
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Test;Integrated Security=True");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("insert into users(name,password)values('"+this.textBox1.Text+"','123456')", conn);
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
this.DialogResult = DialogResult.OK;