Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
| Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 8th, 2007, 11:33 AM
Registered User
 
Join Date: Nov 2007
Location: singapore, singapore, Singapore.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating login form with access database

Hi guys, Im seeking help here. Been trying but yet i cant figure out what is wrong with my code here.

Imports System.data.OleDb

Public Class Login

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

        Dim connStr As String = _
                "Provider=Microsoft.Jet.OleDB.4.0;Data Source=LoanReturn.mdb"
        Dim conn As New OleDbConnection(connStr)
        Dim comm As New OleDbCommand("Select StaffID,Password from Staff where StaffID = " & tbxUsername.Text & " " & _
        " and password = " & tbxPassword.Text & " ", conn)
        conn.Open()

        Dim da As New OleDbDataAdapter(comm)
        Dim ds As New DataSet()
        da.Fill(ds, "StaffID", "Staff")

        Dim reader As OleDbDataReader = comm.ExecuteReader
        If Not reader.Read() Then
            MessageBox.Show("Please enter your username & password again.", "Incorrect Username or Password", MessageBoxButtons.RetryCancel, _
            MessageBoxIcon.Exclamation)

        Else
            Dim f As New LoanReturn
            Me.Hide()
            f.Show()
        End If
        conn.Close()
    End Sub


I have a access database that includes the StaffID and Password. My idea is to get this login form works with the database, meaning the StaffID and Password the user enters should be the same as in the database. When the StaffID and Password are entered correctly, it will get to another form.

I really appreciate if someone able to give me a helping hand. Im a newbie and still doing my best to master this vb 2005.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Login for a VB Studio Access Database cdhansen VB How-To 1 December 4th, 2006 09:17 AM
Creating a database login Apocolypse2005 PHP Databases 3 January 6th, 2006 01:59 PM
Creating a Login Form problem malhyp Dreamweaver (all versions) 10 August 20th, 2005 03:21 AM
Creating Access database at runtime in C# janigorse General .NET 0 September 18th, 2004 06:24 AM
Creating Access database at runtime janigorse Access 0 September 18th, 2004 03:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.