PLEASE!!!! REALLY STUCK ON THIS ONE
-
im creating a form where users can login to a seperate form using a login name and password. I'm trying to compare the users imput for the login to a feild in MS Access and the same with password input in a seperate feild in the same table(PCBank.mdb). if input is correct go to form2. if anyone can help it would be greatly appreciated. code below is my attempt Imports System.Data.OleDb Public Class Form1 Dim conn As OleDbConnection Dim comm As OleDbCommand Dim dr As OleDbDataReader Dim da As OleDbDataAdapter Private Sub connect() conn = New OleDbConnection conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\PCBank.mdb" conn.Open() comm = New OleDbCommand comm.Connection = conn comm.CommandType = CommandType.Text End Sub Private Sub DisplayRecord() Me.txtid.Text = dr.GetString(0) Me.txtpass.Text = dr.GetString(1) End Sub Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click connect() comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'" If txtid.Text = "Managers" = dr.GetString(0) And txtpass.Text = "Managers" = dr.GetString(1) Then My.Forms.Form2.Show() Me.Close() End If End Sub End Class
-
im creating a form where users can login to a seperate form using a login name and password. I'm trying to compare the users imput for the login to a feild in MS Access and the same with password input in a seperate feild in the same table(PCBank.mdb). if input is correct go to form2. if anyone can help it would be greatly appreciated. code below is my attempt Imports System.Data.OleDb Public Class Form1 Dim conn As OleDbConnection Dim comm As OleDbCommand Dim dr As OleDbDataReader Dim da As OleDbDataAdapter Private Sub connect() conn = New OleDbConnection conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\PCBank.mdb" conn.Open() comm = New OleDbCommand comm.Connection = conn comm.CommandType = CommandType.Text End Sub Private Sub DisplayRecord() Me.txtid.Text = dr.GetString(0) Me.txtpass.Text = dr.GetString(1) End Sub Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click connect() comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'" If txtid.Text = "Managers" = dr.GetString(0) And txtpass.Text = "Managers" = dr.GetString(1) Then My.Forms.Form2.Show() Me.Close() End If End Sub End Class
peteyshrew wrote:
Dim conn As OleDbConnection Dim comm As OleDbCommand Dim dr As OleDbDataReader Dim da As OleDbDataAdapter
Why would you make these members ?
peteyshrew wrote:
comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'"
You're truncating the username and password in to one string and using LIKE. What you should be doing is doing a select that checks if a record exists with exactly the username and password that were entered, so the real username and password never get pulled out of the database.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
im creating a form where users can login to a seperate form using a login name and password. I'm trying to compare the users imput for the login to a feild in MS Access and the same with password input in a seperate feild in the same table(PCBank.mdb). if input is correct go to form2. if anyone can help it would be greatly appreciated. code below is my attempt Imports System.Data.OleDb Public Class Form1 Dim conn As OleDbConnection Dim comm As OleDbCommand Dim dr As OleDbDataReader Dim da As OleDbDataAdapter Private Sub connect() conn = New OleDbConnection conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\PCBank.mdb" conn.Open() comm = New OleDbCommand comm.Connection = conn comm.CommandType = CommandType.Text End Sub Private Sub DisplayRecord() Me.txtid.Text = dr.GetString(0) Me.txtpass.Text = dr.GetString(1) End Sub Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click connect() comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'" If txtid.Text = "Managers" = dr.GetString(0) And txtpass.Text = "Managers" = dr.GetString(1) Then My.Forms.Form2.Show() Me.Close() End If End Sub End Class