//APUNTADORES PARA LA BASE DE DATOS
System::Data::OleDb::OleDbConnection^ Cnn;
System::Data::OleDb::OleDbCommand^ Micomando;
System::Data::OleDb::OleDbDataReader^ Datos;
System::String^ strconexion;
System::String^ strsql;
//CONEXION PARA LA BASE DE DATOS
strconexion="Provider=Microsoft.Jet.OLEDB.4.0; Data Source= 'ACCES2003.mdb' ";
Cnn = gcnew OleDbConnection(strconexion);
Cnn->Open();
//SELECCION DE LA BASE DE DATOS
strsql = ("INSERT INTO contacto (NOMBRE, APELLIDO, TELEFONO, ESTADO, CIUDAD, DIRECCION) VALUES ('" +
nombre->Text + "', '" +
apellido->Text + "', '" +
telefono->Text + "', '" +
estado->Text + "', '" +
ciudad->Text + "', '" +
direccion->Text+"');");
Micomando= gcnew OleDbCommand(strsql,Cnn);
try {
Datos = Micomando->ExecuteReader();
MessageBox::Show("Actualizado");
// this->groupBox1->Visible=false;
}
catch (System::Exception^ z)
{
MessageBox::Show("Error Actualizando "+ z->Message );
}
Para que este codigo funcione debe declarar en la parte superior de la ventana
using namespace System::Data::OleDb;
No hay comentarios:
Publicar un comentario