I can't seem to get my ComboBox to refresh after i add new data to the Access Database.
Here's the Code i use to add the new data:
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 qurey
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());
}