1
I have a solution in C# with access database that accepts SELECT, but does not accept INSERT or UPDATE, Follow code of the insert button:
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=|DataDirectory|/teste.accdb";
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "INSERT INTO Tabela1 (Nome) VALUES ( @nome )";
cmd.Parameters.Clear();
cmd.Parameters.Add("@nome", OleDbType.VarChar, 50).Value = textBox1.Text;
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.ExecuteNonQuery();
MessageBox.Show("Inclusão efetuada com sucesso!");
con.Close();
}
catch(Exception)
{
MessageBox.Show("Falha na inserção de registro.");
}
Try to put it as code, otherwise nobody understands...
– Pedro Luzio
@Ivanteles Could post the error generated? Already found the answer?
– Marconi
No error generates Ivan, it runs normal, gives confirmation, but does not insert in the bank
– famelttl