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. Getting information from the database

Getting information from the database

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasesaleshelp
2 Posts 2 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.
  • A Offline
    A Offline
    Aigini
    wrote on last edited by
    #1

    I want to create a Banking Management System, and i have created all the forms in vb.net 2003. The database is created using Microsoft Access 2003. I have stored the username and password of the customers in the table named customer details. This means that each time a user wants to login to this system, they have to enter their username and password and click the login button. Whatever they've entered will be checked with the database. If the information they have entered is correct, then they will be able to login. Else they would not be able to do so, and an error message will pop up. I want to know how should the code be written to be able to do as what i have explained above.

    A 1 Reply Last reply
    0
    • A Aigini

      I want to create a Banking Management System, and i have created all the forms in vb.net 2003. The database is created using Microsoft Access 2003. I have stored the username and password of the customers in the table named customer details. This means that each time a user wants to login to this system, they have to enter their username and password and click the login button. Whatever they've entered will be checked with the database. If the information they have entered is correct, then they will be able to login. Else they would not be able to do so, and an error message will pop up. I want to know how should the code be written to be able to do as what i have explained above.

      A Offline
      A Offline
      Agus Budianto
      wrote on last edited by
      #2

      hope this little code will help you. here i am assuming that in 'customerdetails' table there are fields called 'uname' and 'pwd'. you call this function from you code and check for its return value, if it's true then the login is valid, or otherwise its invalid. for the ConStr property contain connectionstring that will be used to connect to the database, you can use something like this : 'provider=microsoft.jet.oledb.4.0;data source=d:\database\BankingMS.mdb' where you can replace 'd:\database\BankingMS.mdb' with you actual database location.

      'before placing this code, make sure you have imported system.data.oledb

      public function IsLoginValid(byval ConStr as string, byval UName as string, byval Password as string) as boolean
      dim c as new oledbconnection(ConStr)
      dim cmd as oledbcommand=c.createcommand
      dim da as new oledbdataadapter(cmd)
      dim dr as oledbdatareader
      with cmd
      .commandtext="select pwd from customerdetails where uname='" & _
      uname.trim & "'"
      try
      dr=.executereader
      catch x as exception
      messagebox.show("Cant connect to database.")
      finally
      c.close
      end try
      end with
      if dr.hasrows then
      dr.read
      if cstr(dr("pwd")).trim=password.trim then
      return true
      else
      return false
      end if
      else
      return false
      end if
      end function

      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