JoaoSilva21 Posted February 16, 2014 at 02:08 PM Report #545463 Posted February 16, 2014 at 02:08 PM 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 😛
bids Posted March 23, 2014 at 11:38 AM Report #549667 Posted March 23, 2014 at 11:38 AM (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 March 23, 2014 at 11:41 AM by bids Ajude-me?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now