Access 데이터베이스에 새 데이터를 추가 한 후 ComboBox를 새로 고치는 것처럼 보이지 않습니다.ComboBox ChildForm에서 데이터를 추가 한 후 새로 고침
이private void btnAddUser_Click(object sender, EventArgs e)
{
AccountForm actFrm = new AccountForm();
if (actFrm.ShowDialog() == DialogResult.OK)
{
try
{
this.oleDbDataAdapter1.InsertCommand.CommandText =
"INSERT INTO userTable (AccountName, Username, PopServer, PopPort, Psswrd, SmtpServer, SmtpPort, Email)" +
"VALUES ('" + actFrm.txtAccName.Text + "','" + actFrm.txtUsername.Text + "','" + actFrm.txtPop3.Text + "','" + actFrm.txtPop3Port.Text + "','" + actFrm.txtPassword.Text + "','" + actFrm.txtSmtp.Text + "','" + actFrm.txtSmtpPort.Text + "','" + actFrm.txtEmail.Text + "')";
//open the bridge between the application and the datasource
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.InsertCommand.Connection = oleDbConnection1;
//execute the query
this.oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
//close the connection
this.oleDbConnection1.Close();
MessageBox.Show("User Added Successfully"); //inform the user
//tried here to refresh and even open close the myConn connection. to no avail
}
catch (System.Data.OleDb.OleDbException exp)
{
//close the connection
this.oleDbConnection1.Close();
MessageBox.Show(exp.ToString());
}
}
}