Jump to content

Recommended Posts

Posted

Boas tardes pessoal estou a criar um programa e quero fazer um form de login, o projecto já esta ligado a base de dados(access), também já tenho o desing do form feito só falta a programação do botão login.

Quero que compare se o que está escrito na textbox1 e textbox2 e igual ao que está inserido na tabela(funcionarios).

Boa tarde, aguardo ajuda 😛

  • 1 month later...
Posted (edited)
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ole As String = "SELECT count(*) From tbluser where usuário = ? and senha = ?;"
    ' tbluser = nome da tabela que quiseres pôr
    Dim myConnectionString As String = _
    "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\root\Documents\Login BIDS.accdb"
    Dim connection As New OleDbConnection(myConnectionString)
    Dim command As New OleDbCommand(ole, connection)
    command.Parameters.Add("@utilizador", OleDbType.VarChar).Value = txtname.Text
    command.Parameters.Add("@password", OleDbType.VarChar).Value = txtpassword.Text
    connection.Open()
    Dim x As Object
    x = command.ExecuteScalar
    If Integer.Parse(x.ToString) = 1 Then
	    MsgBox("Login efectuado com sucesso!", MsgBoxStyle.Information, "Login")
	    Me.Hide()
	    Form2.Show()
    Else
	    MsgBox("Login mal sucedido", MsgBoxStyle.Information, "Login")
    End If
    connection.Close()
    connection = Nothing
    command = Nothing
   End Sub
End Class
Edited by bids

Ajude-me?

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.