Click here to Skip to main content
11,804,919 members (67,809 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB VB.NET
i want code for login using ms-access
Posted 30-Jan-12 20:36pm
Rajesh Anuhya at 31-Jan-12 2:38am
No effort, Are done some thing?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Of course you don't 'want code': you, being a nice guy, just want any tip or suggestion.
Now, what do you need exactly?
Do you possibly need a form prompting the user for username and password in order to connect to the Access database?
You know, a couple of TextBoxes (with two Labels if you are generous) a Button and you have the GUI.
As about the logic it is just matter of arranging the connection string according to Access database requirements and user input (the TextBoxes content).
If you need sample code the have a look at the gorgeous database section of the CodeProject articles[^].
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

1.)Create a database in Ms. Access e.g. create table, fields - username and password and save the table as LOGIN or what you want.
2.)Click on your table you created (LOGIN or what you wrote) and fill in the data username - yes and password - no.
3.)Go to VB.NET program and open a form and connect the database you created.
4.)To connect a database, check on the top of the menu bar in VB.NET and look for data, then click on add new data source.
5.)Data Source Configuration Wizard appear, click on next. Then you can see a new connection tab, click onto it.
6.)Add connection appears,on Data source the default you can see is Microsoft SQL Server Database File (SqlClient) but since we are using Ms Access we will change it, by clicking the change tab next to it.
7.)Then browse for your database file name by clicking on browse and locate it where it is on your computer (place where you saved your database).
8.)Click on ok,next.
9.)Check the tables and views and click finish.
10.)Go to an empty form and drag the Username and password from the data source. If you cannot see the data source,go to data and then show data sources.
11.) Double click on your form in an empty space and copy this(under Public Class Form1 and above Private sub form1.....):

Dim DbCon As New OleDb.OleDbConnectio
Dim dbUp As New OleDb.OleDbCommand
Dim Read As OleDb.OleDbDataReader

11.)Go back to the design form.
12.)Add 2 buttons on the same form, rename both the buttons,one saying ok and the other as cancel.
13.)Double click on the ok button and enter the codes as follows:

Private Sub Ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DbCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\User\Desktop\Database.mdb"
dbUp.Connection = DbCon
dbUp.CommandType = CommandType.Text
dbUp.CommandText = "Select * from LOGIN where Username=yes and Password=no "
dbUp.Parameters.Add("Username", Data.OleDb.OleDbType.Variant)
dbUp.Parameters.Add("Password", Data.OleDb.OleDbType.Variant)
dbUp.Parameters("Username").Value = UsernameTextBox.Text
dbUp.Parameters("Password").Value = PasswordTextBox.Text
Read = dbUp.ExecuteReader
With Read
If .Read Then
MessageBox.Show("Invalid Username or Password")
End If
End With

14.)Then go to the design page again and double click on cancel button and copy the following:

If MessageBox.Show("Do you want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
End If
End Sub

15.) Once you have done that run your program and check whether the codes worked.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Start reading: ASP.NET Membership[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 3,205
1 Maciej Los 1,950
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100