|
-
Sep 13th, 2005, 11:02 AM
#1
Thread Starter
New Member
Security Login
I am relatively new to programming and could use some direction from someone more experienced.
What I am trying to do is create a login routine for a VB.Net app I have created. I need to promp the user to enter a username and password, then compare their password with the password field in a SQL Server database for their userid. If they match, then go ahead and open the first form in the app.
Basically I need someone to show me the syntax I should follow to connect to the database, formulate and run a select statement based on the userid they enter in the textbox, then compare the password they entered in a textbox to the one in the database. I'd like to use ADO.NET, but if there are other ways to do this, please feel free to respond. Thanks in advance!
-
Sep 13th, 2005, 11:31 AM
#2
Lively Member
Re: Security Login
Welcome to the forums!
First you need to get the connection string.
http://www.connectionstrings.com/
This site has lots of them. Then you need to create a data adater and a data table and then just fill the table from the adapter. I'll post code if you need it.
"I aim to misbehave."
Captain Mal Reynolds
-
Sep 13th, 2005, 11:36 AM
#3
Lively Member
Re: Security Login
VB Code:
Dim oConn As New SqlConnection = "Connection String Goes Here"
Dim oAdpt As New SqlDataAdapter("Select * From Employee", oConn)
Dim oDTbl As New DataTable
oADpt.Fill(oDTble)
Dim oTempRow As DataRow
For Each oTempRow In oDTbl.Rows
If oTempRow.Item("EmployeeID") = txtEmpID.Text Then
If oTempRow.Item("Password") = txtPassword.Text Then
'User Logs In
Else
'User Doesn't Log In
End If
End If
Next
Last edited by Neoharuo; Sep 13th, 2005 at 11:40 AM.
"I aim to misbehave."
Captain Mal Reynolds
-
Sep 13th, 2005, 12:03 PM
#4
Thread Starter
New Member
Re: Security Login
That is exactly what I needed. It worked perfectly. Thanks Neoharuo!
-
Sep 13th, 2005, 12:23 PM
#5
Lively Member
Re: Security Login
 Originally Posted by aarondba
That is exactly what I needed. It worked perfectly. Thanks Neoharuo!
NP glad to be of help!
"I aim to misbehave."
Captain Mal Reynolds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|