Beispiel #1
0
        public bool acceso(String usu, String contra)
        {
            servidor misvr = new servidor("localhost", "insunipue");

            SqlConnection miconexion = new SqlConnection("Data Source=" +
                                                         misvr.Svractual +
                                                         "; Initial catalog=" +
                                                         misvr.Bdatos +
                                                         "; Integrated security=true");

            misvr.MyQuery = "select * from usuario where nombre_usr ='******'and contra_usr = '******'";

            miconexion.Open();
            //Datos conecta = new Datos();
            //conecta.Conectar();
            SqlCommand    consulta = new SqlCommand(misvr.MyQuery, miconexion);
            SqlDataReader ejecuta  = consulta.ExecuteReader();

            if (ejecuta.Read() == true)
            {
                miconexion.Close();
                return(true);
            }
            else
            {
                miconexion.Close();
            }
            return(false);
        }
Beispiel #2
0
        SqlConnection conn;   // cadena de conexion

        public bool Conectar()
        {
            conn = new SqlConnection();

            servidor misvr = new servidor("localhost", "insunipue");

            misvr.MyCadCon = "Data Source=" +
                             misvr.Svractual +
                             "; Initial catalog=" +
                             misvr.Bdatos +
                             "; Integrated security=true";


            conn.ConnectionString = misvr.MyCadCon;
            try
            {
                conn.Open();
                return(true);
            }
            catch (Exception error)
            {
                MessageBox.Show("Error al conectarse a la base de datos" + error.Message);
                return(false);
            }
        }