Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. PLEASE!!!! REALLY STUCK ON THIS ONE

PLEASE!!!! REALLY STUCK ON THIS ONE

Scheduled Pinned Locked Moved Visual Basic
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    peteyshrew
    wrote on last edited by
    #1

    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

    C J 2 Replies Last reply
    0
    • P peteyshrew

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      1 Reply Last reply
      0
      • P peteyshrew

        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

        J Offline
        J Offline
        jhoga
        wrote on last edited by
        #3

        :confused:I have have not look at this in detail but does not msaccess require you use "*" as a wild card instead of the SQL "%"/ jhoga

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups