473,511 Members | 15,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create a login form that checks info against a database

8 New Member
Hi. iv been able to create a loin form bu I am stuck on the code. what i want is for a manager to be able to enter his manager ID and password and it to be checked against a database. I have set up the various connections but I cant figure out the code.
Thanks
Feb 18 '08 #1
2 1681
debasisdas
8,127 Recognized Expert Expert
when the user logs in to database using username and password

1.check for existance of the user name and the corresponding password .
2. if it exists then login.
else
deny login.
Feb 18 '08 #2
jamesd0142
469 Contributor
Here's an example using sql server 2000

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2.  
  3. Public Class Form1
  4.  
  5.     '---Database Declarations
  6.     Dim Cmd As OleDb.OleDbCommand
  7.     Dim Con As OleDb.OleDbConnection
  8.     Dim Sql As String = Nothing
  9.     Dim Reader As OleDb.OleDbDataReader
  10.     Dim ComboRow As Integer = -1
  11.     Dim Columns As Integer = 0
  12.     Dim Category As String = Nothing
  13.     Dim da As System.Data.OleDb.OleDbDataAdapter
  14.     Dim oDS2 As New System.Data.DataSet
  15.  
  16.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  17.         oDS2.Clear()
  18.         Dim Password As String
  19.         Sql = "select * from Users where [Login] = " & "'" & txtLogin.Text & "'"
  20.         Con = New OleDbConnection("Provider=sqloledb;Data Source=Server;Initial Catalog=Database;User ID=sa;Password=Password")
  21.         Con.Close()
  22.         Cmd = New OleDb.OleDbCommand(Sql, Con)
  23.         Try
  24.             Con.Open()
  25.             da = New OleDbDataAdapter(Sql, Con)
  26.             da.Fill(oDS2, "login")
  27.             If oDS2.Tables("login").Rows.Count = 1 Then
  28.                 Password = oDS2.Tables("login").Rows(0)("Password")
  29.  
  30.                 If txtPassword.Text = Password Then
  31.                     'login successful
  32.                     Form2.Show()
  33.                     Me.Hide()
  34.                 End If
  35.             End If
  36.         Catch
  37.         End Try
  38.     End Sub
  39. End Class
  40.  
Feb 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
12158
by: GreggTB | last post by:
I've got an page (LOGIN.ASPX) that receives the user's login information. During the page load, it checks the credentials against a database and, if validation is successful, creates an instance of...
2
2855
by: Shakun | last post by:
Hi All, This is my 1st posting to this group. Can any1 help me with the "Remember Me" which is there in a login form. Im pasting the code below. Im not able to set a cookie.. Thanks, Shakun...
7
4169
by: Andrea | last post by:
Hi there! I have to do a php script that daily surf a webpage (I do it with crontab) and collect some data. The proble is that to access that webpage I have to do a login. I have the login data,...
2
1923
by: dylanhughes | last post by:
I'm looking for an example of a login system that has multiple fields (2 to be exact) + password. e.g username, company name and password, the user, company and password are checked against a mysql...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.