joven Posted May 6, 2009 at 10:27 AM Report #261811 Posted May 6, 2009 at 10:27 AM Boa tarde Alguem tem algum exemplo de incerção de dados numa base de dados da MS Access. ? Obrigado
amiloM1425 Posted May 6, 2009 at 10:44 AM Report #261813 Posted May 6, 2009 at 10:44 AM Aqui está um exemplo de uma inserção: public static void inserirCliente(ClienteInfo cliente) { OleDbCommand command; OleDbConnection conn = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;data source=PATH_PARA_A_BD"); try { conn.Open(); command = new OleDbCommand("INSERT INTO cliente (nome, email, fax, telefone, tipoNotificacao) VALUES (?,?,?,?,?)", conn); command.Parameters.AddWithValue("@nome", cliente.getNome()); command.Parameters.AddWithValue("@email", cliente.getEmail()); command.Parameters.AddWithValue("@fax", cliente.getFax()); command.Parameters.AddWithValue("@telefone", cliente.getTelefone()); command.Parameters.AddWithValue("@tipoNotificacao", cliente.getTipoNotificacao()); command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.Message); } finally { conn.Close(); } }
joven Posted May 6, 2009 at 04:34 PM Author Report #261896 Posted May 6, 2009 at 04:34 PM o OleDbCommand pode ser um comando sql gerado por uma consulta Insert do Access?
amiloM1425 Posted May 7, 2009 at 08:36 AM Report #262040 Posted May 7, 2009 at 08:36 AM como assim? Pegares na query gerada pelo Access e usá-la? Sim podes. Podes usar a query que quiseres, desde que não contenha erros claro.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now