if((this->CAMPO1->Text == "")||(this->CAMPO2->Text ==""))
{
MessageBox::Show("Datos Incompletos");
}
else
{
//APUNTADORES PARA LA BASE DE DATOS
System::Data::OleDb::OleDbConnection^ link;
System::Data::OleDb::OleDbCommand^ ejecutar;
System::Data::OleDb::OleDbDataReader^ Datos;
System::String^ linkstring;
System::String^ db;
//CONEXION PARA LA BASE DE DATOS
linkstring="Provider=Microsoft.ACE.OLEDB.12.0;Data Source='ACCESS2007.accdb'";
link = gcnew OleDbConnection(linkstring);
link->Open();
//SELECCION DE LA BASE DE DATOS
db=("SELECT * FROM TABLA WHERE CAMPO= '" + this->CAMPO1->Text + "' ; ");
ejecutar= gcnew OleDbCommand(db,link);
Datos = ejecutar->ExecuteReader();
if (Datos->Read())
{
String ^ user;
String ^ pass;
user = Datos->GetString(0); //Posicion del Usuario en la Base de datos
pass = Datos->GetString(1); //Posicion de la Clave en la base de datos
//Las posiciones se cuenta iniciando el numero 0
if((this->CAMPO1->Text == user)&&(this->CAMPO2->Text == pass))
{
MessageBox::Show("Bienvenido "+user+"");
Form ^ VARIABLE = gcnew opciones();
VARIABLE->Show();
}
else
MessageBox::Show("Acceso denegado");
}
CAMPO1->Clear();
CAMPO2->Clear();
}
No hay comentarios:
Publicar un comentario