| | |
Test Login of different user in a database
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 72
Reputation:
Solved Threads: 0
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.......
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.......
•
•
Join Date: Jan 2008
Posts: 24
Reputation:
Solved Threads: 0
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
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.
![]() |
Similar Threads
- Simple ASP.Net Login Page using C# (C#)
- is there a way to take user login from SQL database (ASP.NET)
- PHP Logic for Online Test (PHP)
- php + mysql (PHP)
- Create a Login page (asp,c#,sql2k5) (C#)
- connecting java to mysql database (Java)
- Login and retrieve user data from database (ASP.NET)
- login script using sessions (PHP)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Automatic Files Sorting and Folders Creation
- Next Thread: Datagride column width
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial server soap sql table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





