Jump to content

C# + mysql com xampserver


martinhocosta
 Share

Recommended Posts

boa tarde,

estou a tentar ligar a uma base de dados mysql com o c# .

e aparece-me a seguinte Exception

"erro: Unable to read data from the transport connection: Uma tentativa de ligação falhou porque o componente ligado não respondeu

correctamente após um período de tempo, ou a ligação estabelecida falhou

porque o anfitrião ligado não respondeu."

deixo aqui o codigo c#:

    private MySqlConnection conexao;
	public void cadastro(modelo mo)
	{
		string caminho = "SERVER=127.0.0.1;PORT=83;DATABASE=test;UID=root;PASSWORD=;";
		try
		{
			conexao = new MySqlConnection(caminho);
			conexao.Open();


			string inserir = "INSERT INTO login(user, pass)values('" + mo.NUser + "', '" + mo.NPass + "')";
			MySqlCommand comandos = new MySqlCommand(inserir, conexao);
			comandos.ExecuteNonQuery();
			conexao.Close();
		}
		catch (Exception ex)
		{
			throw new Exception("erro: " + ex.Message);
		}
	}

Não estou a entender o erro

Link to comment
Share on other sites

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
 Share

×
×
  • 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.