Problems connecting mysql with asp.net c #

2

A small problem appeared, which in my old application worked normally.

My DAL Class is not connecting in Mysql. Being all the connection parameters, I believe it is correct.

MyDALthatmakestheconnection.

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingGeax1.Model;usingMySql.Data;usingMySql.Data.MySqlClient;namespaceGeax1.DAL{publicclassVeiculosDAL{publicstaticvoidcadastra(_Veiculosobj){using(varconn=newMySqlConnection("server=127.0.0.1;Database=xpto;User ID=root;Password='';"))
        {
            try
            {
                conn.Open();
                String InsertVeiculos = ("INSERT INTO tab_veiculo (placa,quilometragem,cor,tipo,ano,chassi,modelo) VALUES(@placa, @cor, @tipo, @ano, @chassi, @modelo)");

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = InsertVeiculos;
                cmd.Connection = conn;
                cmd.Parameters.AddWithValue("@placa", obj.Placa1);
                cmd.Parameters.AddWithValue("@quilometragem", obj.Quilometragem1);
                cmd.Parameters.AddWithValue("@cor", obj.Cor1);
                cmd.Parameters.AddWithValue("@tipo", obj.Tipo1);
                cmd.Parameters.AddWithValue("@ano", obj.Ano1);
                cmd.Parameters.AddWithValue("@chassi", obj.Chassi1);
                cmd.Parameters.AddWithValue("@modelo", obj.Modelo1);
                cmd.ExecuteNonQuery();

            }
            catch (Exception e)
            {
                throw e;
            }
        }
    }
}

}

Note: My WAMP is on.

    
asked by anonymous 24.09.2014 / 06:17

1 answer

2

Permission is missing, however root the user is:

Run the following:

CREATE USER 'usuario'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'usuario'@'localhost' WITH GRANT OPTION;
CREATE USER 'username'@'%' IDENTIFIED BY 'senha';
GRANT ALL PRIVILEGES ON *.* TO 'usuario'@'%' WITH GRANT OPTION;

Restart WAMP.

    
24.09.2014 / 06:24