| | |
login with ms access table
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 192
Reputation:
Solved Threads: 16
I have a login control, when user presses login I want to check if he exists in the table.
I made a connection to database, and now how do I check if he exists?
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim sqlstring As String
sqlstring = "SELECT id FROM tbl_users WHERE name = " & Login1.UserName & "AND password= " & Login1.Password
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Dokumente und Einstellungen\USER\Eigene Dateien\Login.mdb;User Id=admin;Password=;")
Dim dbcomm As New OleDbCommand(sqlstring, cn)
cn.Dispose()
End Sub
I made a connection to database, and now how do I check if he exists?
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim sqlstring As String
sqlstring = "SELECT id FROM tbl_users WHERE name = " & Login1.UserName & "AND password= " & Login1.Password
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Dokumente und Einstellungen\USER\Eigene Dateien\Login.mdb;User Id=admin;Password=;")
Dim dbcomm As New OleDbCommand(sqlstring, cn)
cn.Dispose()
End Sub
•
•
Join Date: Jul 2007
Posts: 192
Reputation:
Solved Threads: 16
I need some more help, I don't know how to go about it
In web.config I have
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
<authentication mode="Forms"/>
In my login form I have a login control with this code
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim sqlstring As String
sqlstring = "SELECT id FROM tbl_users WHERE name = " & Login1.UserName & "AND password= " & Login1.Password
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Dokumente und Einstellungen\USER\Eigene Dateien\Login.mdb;User Id=admin;Password=;")
Dim dbcomm As New OleDbCommand(sqlstring, cn)
cn.Dispose()
End Sub
Now if I add to the above code
if dbcomm.executescalar <> nothing then ??????? what do I do to tell my web.config login was successfull?
In web.config I have
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
<authentication mode="Forms"/>
In my login form I have a login control with this code
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim sqlstring As String
sqlstring = "SELECT id FROM tbl_users WHERE name = " & Login1.UserName & "AND password= " & Login1.Password
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Dokumente und Einstellungen\USER\Eigene Dateien\Login.mdb;User Id=admin;Password=;")
Dim dbcomm As New OleDbCommand(sqlstring, cn)
cn.Dispose()
End Sub
Now if I add to the above code
if dbcomm.executescalar <> nothing then ??????? what do I do to tell my web.config login was successfull?
Try this article.
It will clarify your doubts about form authentication.
http://www.eggheadcafe.com/articles/20020906.asp
If you think that's difficult to digest, go through this one..
http://www.csse.monash.edu.au/course...004/login.html
Hope this helps.
It will clarify your doubts about form authentication.
http://www.eggheadcafe.com/articles/20020906.asp
If you think that's difficult to digest, go through this one..
http://www.csse.monash.edu.au/course...004/login.html
Hope this helps.
Last edited by bala24; Jun 27th, 2008 at 2:45 am.
Michelangelo
"The best place to find a helping hand is at the end of your own arm"
"The best place to find a helping hand is at the end of your own arm"
•
•
Join Date: Jul 2007
Posts: 192
Reputation:
Solved Threads: 16
•
•
•
•
Try this article.
It will clarify your doubts about form authentication.
http://www.eggheadcafe.com/articles/20020906.asp
If you think that's difficult to digest, go through this one..
http://www.csse.monash.edu.au/course...004/login.html
Hope this helps.
•
•
Join Date: Jul 2007
Posts: 192
Reputation:
Solved Threads: 16
Here is what I have so far, the bold line gives me an error, besides does this code look right?
Dim myid As Long
Dim sqlstring As String
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Dokumente und Einstellungen\USER\Eigene Dateien\Login.mdb;User Id=admin;Password=;")
Dim dr As New OleDbDataReader
sqlstring = "SELECT id FROM tbl_users WHERE name = ? AND password= ?"
Dim dbcomm As New OleDbCommand(sqlstring, cn)
dbcomm.Parameters.AddWithValue("name", Login1.UserName)
dbcomm.Parameters.AddWithValue("password", Login1.Password)
If dbcomm.ExecuteScalar <> Nothing Then
dr = dbcomm.ExecuteReader()
myid = dr(1)
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(myid, False)
End If
cn.Dispose()
Dim myid As Long
Dim sqlstring As String
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Dokumente und Einstellungen\USER\Eigene Dateien\Login.mdb;User Id=admin;Password=;")
Dim dr As New OleDbDataReader
sqlstring = "SELECT id FROM tbl_users WHERE name = ? AND password= ?"
Dim dbcomm As New OleDbCommand(sqlstring, cn)
dbcomm.Parameters.AddWithValue("name", Login1.UserName)
dbcomm.Parameters.AddWithValue("password", Login1.Password)
If dbcomm.ExecuteScalar <> Nothing Then
dr = dbcomm.ExecuteReader()
myid = dr(1)
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(myid, False)
End If
cn.Dispose()
Well you don't need that line at all.
The ExecuteScalar method returns a single value eg the number of records affected in an update query.
In your case it holds the id of the user which is an authenticated user.
If he is not, the ExecuteScalar will return nothing.
So what you could do id this.
Hope its clear.
The ExecuteScalar method returns a single value eg the number of records affected in an update query.
In your case it holds the id of the user which is an authenticated user.
If he is not, the ExecuteScalar will return nothing.
So what you could do id this.
ASP.NET Syntax (Toggle Plain Text)
Dim strid as string 'Assuming your id is a string value strid=dbcomm.ExecuteScalar() If not strid is nothing Then System.Web.Security.FormsAuthentication.RedirectFromLoginPage(strid, False) End If
Hope its clear.
Michelangelo
"The best place to find a helping hand is at the end of your own arm"
"The best place to find a helping hand is at the end of your own arm"
![]() |
Similar Threads
- Simple ASP.Net Login Page using C# (C#)
- Custom page to login to Yahoo, Gmail, MSN etc (JavaScript / DHTML / AJAX)
- Retrieving Fields from MS Access (VB.NET)
- problem in accessin table values from access database.. (Java)
- Creating a Login Page (ASP)
- login Access Level (VB.NET)
- code for login and password..using vb6 (Visual Basic 4 / 5 / 6)
- Login used to work (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: How to embed OCX file.
- Next Thread: messenger on custom web page
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dialog dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis image javascript list listbox login microsoft mono mouse mssql multistepregistration news numerical opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





