User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,351 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,205 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 843 | Replies: 9 | Solved
Reply
Join Date: May 2008
Posts: 4
Reputation: santhanalakshmi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
santhanalakshmi santhanalakshmi is offline Offline
Newbie Poster

Login page

  #1  
May 30th, 2008
Hi,
I was new to c# and asp.net .I want to create a simple login page using ASP.net with c# code behind.I had 2 textboxs(username and id) and 1 button control.I stored all the username and id in MS ACCESS database.Database name "user.mdb" and table name
"table1" (only 2 fields username and password).Once users enter their username & id,and by clicking button control,it must check into the database.If is it in database means ,this login page call other .aspx page.if is it not in database means "error should arise not in the database".I dont how to proceed .........and i need a full code regarding on this.Please help me...........
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 287
Reputation: ericstenson is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: Login page

  #2  
May 30th, 2008
Search and you shall find.
--
"Dummy."
Reply With Quote  
Join Date: Aug 2006
Posts: 3
Reputation: thebigo is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
thebigo's Avatar
thebigo thebigo is offline Offline
Newbie Poster

Re: Login page

  #3  
Jun 1st, 2008
Why not use Session Variables? Once the user is verified create a Session variable (e.g. Session("Verified") = "Yes"). In the Page Load check if the value is Yes. Much easier and quicker than a database access plus MS Access sucks as a multi-user database.
Reply With Quote  
Join Date: May 2008
Location: Chennai
Posts: 41
Reputation: rajarajan07 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
rajarajan07's Avatar
rajarajan07 rajarajan07 is offline Offline
Light Poster

Re: Login page

  #4  
Jun 1st, 2008
Please put some effort to write codings, I don't know how to clear your doubts. Are you asking for full coding from connection establishment upto validation.
If you got your answer, please mark the thread as Solved.
Thanks & Regards,
RajaRajan. R

rajarajan07@rediffmail.com
Reply With Quote  
Join Date: May 2008
Posts: 2
Reputation: girigdk is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
girigdk's Avatar
girigdk girigdk is offline Offline
Newbie Poster

Re: Login page

  #5  
Jun 2nd, 2008
First you need to get all the usernames and ids from the table, and then compare each with the username and id entered in the textboxes.

I will provide the code for sql database and try it for your MS ACCESS database.

Using System.Data.SqlClient;

Next in Button Click Event:
------------------------------

  1. SqlConnection con=new SqlConnection();
  2. con.ConnectionString="server=localhost;database=master;user id=sa";
  3. (Specify as per ur databse)
  4. con.Open();
  5. SqlDataAdaptor da=new SqlDataAdapor("select * from tablename",con);
  6. DataSet ds=new DataSet();
  7. da.fill(ds,"tablename");

**Comapring the validations**

  1. for(int i=0;i<=ds.Tables["Tablename"].Rows.count;i++)
  2. {
  3. if(textBox1.Text==ds.Tables ["Tablename"].Rows[i][0])
  4.  
  5. {
  6. if(textBox2.Text==ds.Tables ["Tablename"].Rows[i][1])
  7. Server.Transfer("nextpage.aspx");
  8. else
  9. {
  10. Response.Write("Invalid");
  11. }
  12. else
  13. Response.Write("Invalid");
  14.  
  15.  
  16. }
  17. }


====Try the above Code and let me know the results==========
Last edited by peter_budo : Jun 4th, 2008 at 3:44 am. Reason: Keep It Organized - please use [code] tags
GIRI GAADU
Reply With Quote  
Join Date: May 2008
Posts: 4
Reputation: santhanalakshmi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
santhanalakshmi santhanalakshmi is offline Offline
Newbie Poster

Re: Login page

  #6  
Jun 4th, 2008
Originally Posted by girigdk View Post
First you need to get all the usernames and ids from the table, and then compare each with the username and id entered in the textboxes.

I will provide the code for sql database and try it for your MS ACCESS database.

Using System.Data.SqlClient;

Next in Button Click Event:
------------------------------

SqlConnection con=new SqlConnection();
con.ConnectionString="server=localhost;database=master;user id=sa";
(Specify as per ur databse)
con.Open();
SqlDataAdaptor da=new SqlDataAdapor("select * from tablename",con);
DataSet ds=new DataSet();
da.fill(ds,"tablename");

**Comapring the validations**

for(int i=0;i<=ds.Tables["Tablename"].Rows.count;i++)
{
if(textBox1.Text==ds.Tables ["Tablename"].Rows[i][0])

{
if(textBox2.Text==ds.Tables ["Tablename"].Rows[i][1])
Server.Transfer("nextpage.aspx");
else
{
Response.Write("Invalid");
}
else
Response.Write("Invalid");


}
}


====Try the above Code and let me know the results==========


Hi
I try for Ms access database .But i got 2 errors and 2 warning message.The list of errors are:
Error 1 The name 'da' does not exist in the current context.
Error 2 'System.Data.DataRowCollection' does not contain a definition for 'count' .
Warning 3 Possible unintended reference comparison; to get a value comparison, cast the right hand side to type 'string'.
Warning 4 Possible unintended reference comparison; to get a value comparison, cast the right hand side to type 'string'

Here's my code:

  1. using System;
  2. using System.Data;
  3. using System.Data.OleDb;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12.  
  13. public partial class sample1_login : System.Web.UI.Page
  14. {
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17.  
  18. }
  19. protected void Button1_Click(object sender, EventArgs e)
  20. {
  21. OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\login.mdb;Persist Security Info=False");
  22. conn.Open();
  23. OleDbCommand com = new OleDbCommand("select * from logintable",conn);
  24. DataSet ds=new DataSet();
  25. da.fill(ds,"logintable");
  26.  
  27. for (int i = 0; i <= ds.Tables["Tablename"].Rows.count; i++)
  28. {
  29. if (TextBox1.Text == ds.Tables["Tablename"].Rows[i][0])
  30. {
  31. if (TextBox2.Text == ds.Tables["Tablename"].Rows[i][1])
  32. {
  33. Server.Transfer("reservation.aspx");
  34. }
  35. else
  36. {
  37. Response.Write("Invalid");
  38. }
  39. }
  40. else
  41. {
  42.  
  43. Response.Write("Invalid");
  44.  
  45. }
  46. }
  47. }
  48. }


Thanks girigdk.......
Last edited by peter_budo : Jun 4th, 2008 at 3:44 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Mar 2008
Posts: 39
Reputation: srikanthkadem is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
srikanthkadem srikanthkadem is offline Offline
Light Poster

Re: Login page

  #7  
Jun 4th, 2008
hi,
in this code errors are,
da.fill(ds,"logintable"); here where did u create object da for dataadapter.so create object then ur problems will be solved.
suggetion: if (TextBox2.Text == ds.Tables["Tablename"].Rows[i][1])
{
// create session for user which can be useful in throughout the appication
Server.Transfer("reservation.aspx");
}

hope it will be helpful
got solution ?, please mark the thread as Solved. Thanks & Regards,
srikanth kadem
srikanthkadem@rediffmail.com
Reply With Quote  
Join Date: May 2008
Posts: 4
Reputation: santhanalakshmi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
santhanalakshmi santhanalakshmi is offline Offline
Newbie Poster

Re: Login page

  #8  
Jun 5th, 2008
Originally Posted by srikanthkadem View Post
hi,
in this code errors are,
da.fill(ds,"logintable"); here where did u create object da for dataadapter.so create object then ur problems will be solved.
suggetion: if (TextBox2.Text == ds.Tables["Tablename"].Rows[i][1])
{
// create session for user which can be useful in throughout the appication
Server.Transfer("reservation.aspx");
}

hope it will be helpful


hi,
I got the answer ....................Its fine
Reply With Quote  
Join Date: Mar 2008
Posts: 39
Reputation: srikanthkadem is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
srikanthkadem srikanthkadem is offline Offline
Light Poster

Re: Login page

  #9  
Jun 5th, 2008
hey,
glad that u got soln....please mark the thread as solved....
got solution ?, please mark the thread as Solved. Thanks & Regards,
srikanth kadem
srikanthkadem@rediffmail.com
Reply With Quote  
Join Date: May 2008
Posts: 10
Reputation: JackyGZ is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
JackyGZ JackyGZ is offline Offline
Newbie Poster
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 11:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC