Jump to content

Recommended Posts

Posted

É fácil, tens de sacar antes demais o pacote da mysql instalas no computador e tens de chamar a referência, depois instalas o microsoft connector(será necessário todos os utilizadores desse programa usar), depois é só fazer o seguinte!

using MySql.Data.MySqlClient;

e no código:

string MyConString = "SERVER=localhost(muda isto);" +
                    "DATABASE=mete a base de dados;" +
                    "UID=user;" +
                    "PASSWORD=password;";
            try
            {
                MySqlConnection mysqlCon = new MySqlConnection(MyConString);
                mysqlCon.Open();
                string strSQL = "SELECT * FROM aquiabd";
                MySqlCommand mysqlCmd = new MySqlCommand(strSQL, mysqlCon);
                MySqlDataReader mysqlReader = mysqlCmd.ExecuteReader();
                while (mysqlReader.Read())
                {
                    if (aqui podes comparar == (mysqlReader.GetString(1)) && aquitambem == (mysqlReader.GetString(16)))
                    {
                        MessageBox.Show("Connectado com sucesso");
                        user = mysqlReader.GetString(1);
                        txtPassword.Enabled = false;
                        txtUsername.Enabled = false;
                        btnLogin.Enabled = false;
                    }
                }

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.