I used this code for so long with no problem. However, right now as I try to insert into the database, I get this error
ERROR [07002] [MICROSOFT] ODBC MICROSOFT ACCESS DRIVER] TOO FEW PARAMETERS EXPECTED 2.
Can someone let me know what I am doing wrong?
if (txtFullName.Text == "" || txtPostcode.Text == "")
{
MessageBox.Show("Please enter appropriate details in order to proceed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (txtFullName.Text != "" && txtFullName.Text != "")
{
OdbcCommand cmd = new OdbcCommand("INSERT INTO [Entry] ([FullName], Postcode) Values(@A, @B)", ConnectDb);
cmd.Parameters.AddWithValue("@A", "HI");
cmd.Parameters.AddWithValue("@B", "BY");
ConnectDb.Open();
try
{
int res = cmd.ExecuteNonQuery();
if (res > 0)
{
DialogResult dialogResult = MessageBox.Show("New Allocator saved! would you like to exit? ", "Saved", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
//BackToAdminMainMenu();
}
if (dialogResult == DialogResult.No)
{
//Clear();
}
}
}
catch (Exception err)
{
MessageBox.Show("A database error has occurred: " + Environment.NewLine + err.Message);
}
finally
{
ConnectDb.Close();
}
}