A first chance exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll
Additional information: Connection must be valid and open
The thread 0xc00 has exited with code 0 (0x0).
The program '[2824] Sistema.vshost.exe: Managed' has exited with code -532459699 (0xe0434f4d).
Login.vb
Public Class Login
Private Sub fechar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fechar.Click
Close()
End Sub
Private Sub entrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles entrar.Click
Dim Validar As MySql.Data.MySqlClient.MySqlDataReader = Validar_Funcionario(" Select * from login where Usu = '" & usuario.Text & " and Sen = '" & senha.Text & "' ")
If Conexao_Mysql() Then
If Validar.HasRows = True Then
While Validar.Read
MessageBox.Show(Validar.Item(1).ToString)
End While
End If
End If
Validar.Close()
End Sub
End Class
Modulo.vb
Module Modulo
Public Conexao As MySql.Data.MySqlClient.MySqlConnection
Function Conexao_Mysql() As Boolean
Dim Conexao = New MySql.Data.MySqlClient.MySqlConnection("Server=localhost;Database=projeto;Uid=root;Pwd=janio1")
Try
Conexao.Open()
Return True
Catch erro As Exception
MessageBox.Show("Ocorreu um erro ao inicializar a conexão: " & erro.ToString())
Return False
End Try
End Function
Function Validar_Funcionario(ByVal Query As String) As MySql.Data.MySqlClient.MySqlDataReader
Dim Comando As New MySql.Data.MySqlClient.MySqlCommand(Query, Conexao)
Return Comando.ExecuteReader()
End Function
End Module
Pergunta
mestre fyoda
Erro:
A first chance exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll
Additional information: Connection must be valid and open
The thread 0xc00 has exited with code 0 (0x0).
The program '[2824] Sistema.vshost.exe: Managed' has exited with code -532459699 (0xe0434f4d).
Login.vb
Modulo.vbLink para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.