Test Login of different user in a database

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 72
Reputation: geetajlo is an unknown quantity at this point 
Solved Threads: 0
geetajlo geetajlo is offline Offline
Junior Poster in Training

Test Login of different user in a database

 
0
  #1
Feb 29th, 2008
hi can any1 help me ...
i want to let different user to log in a system from a database.
i know it must check it from the database bt i don't know how to do it.
i just want to use only 2 columns.
one for username and the other for password. n as for the rows it will keep increasing....
Help me plzzz.......
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 24
Reputation: suganzeni is an unknown quantity at this point 
Solved Threads: 0
suganzeni suganzeni is offline Offline
Newbie Poster

Re: Test Login of different user in a database

 
0
  #2
Mar 4th, 2008
Hi
Create a data base.
Create a table for login with two columns one for user name and other for password.
Create a dataset.
Assign the data base table to the dataset.
Get the user name from the user and check weather it matches with the user name in the login table.Do the same for password too.
If it matches allow them to login

Sample Coding: With VB.NET and SQL SERVER
//CReate DataBase
Try
If Not File.Exists("\My Documents\myinsurance.sdf") Then
Dim engine As New SqlCeEngine
engine = New SqlCeEngine
engine.LocalConnectionString = "Data Source=\My Documents\myinsurance.sdf; " + "Password="
engine.CreateDatabase()
'To Create the Data base
engine.Dispose()
End If
Catch sqlex As SqlCeException
MsgBox(sqlex.Message)
End Try

//Table Creation
Public Function createtable()
Dim cn1 As SqlCeConnection = Nothing
cn1 = New SqlCeConnection("Data Source=\My Documents\myinsurance.sdf; " + "Password=")
Try
If cn1.State = ConnectionState.Open Then
cn1.Close()
End If
cn1.Open()

Dim sqlCreateTable As SqlCeCommand = cn1.CreateCommand()
sqlCreateTable.CommandText = "CREATE TABLE TABLENAME(fieldname datatype, fieldname datatype)"
sqlCreateTable.ExecuteNonQuery()
cn1.Close()
Catch sce As SqlCeException
MessageBox.Show(sce.Message)
End Try
End Function

Insert values to the data base by usind INSERT INTO TABLENAME(fieldname,fieldname)VALUES('value1','value2') command

'Now assign the table to dataset
dim ds as new DataSet
dim row_count as integer
Dim da3 As New SqlCeDataAdapter("SELECT * FROM TABLENAME", cn3)
da3.Fill(ds, "TABLENAME")
row_count = ds.Tables("TABLENAME").Rows.Count
For row_index = 0 To row_count - 1 Step 1
if username.Text=ds.Tables("TABLENAME").Rows(row_index).Item("Username") AND password.Text=ds.Tables("TABLENAME").Rows(row_index).Item("Password") THEN
//Now allow the uer to login
// username.Text and password.Text=The value receviced from user in run time
Next row_index
Last edited by suganzeni; Mar 4th, 2008 at 12:15 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC