•
•
•
•
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
![]() |
•
•
Join Date: May 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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...........
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...........
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
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:
------------------------------
**Comapring the validations**
====Try the above Code and let me know the results==========
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:
------------------------------
ASP.NET Syntax (Toggle Plain Text)
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**
ASP.NET Syntax (Toggle Plain Text)
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==========
Last edited by peter_budo : Jun 4th, 2008 at 3:44 am. Reason: Keep It Organized - please use [code] tags
GIRI GAADU
•
•
Join Date: May 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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:
ASP.NET Syntax (Toggle Plain Text)
using System; using System.Data; using System.Data.OleDb; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class sample1_login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\login.mdb;Persist Security Info=False"); conn.Open(); OleDbCommand com = new OleDbCommand("select * from logintable",conn); DataSet ds=new DataSet(); da.fill(ds,"logintable"); 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("reservation.aspx"); } else { Response.Write("Invalid"); } } else { Response.Write("Invalid"); } } } }
Thanks girigdk.......
Last edited by peter_budo : Jun 4th, 2008 at 3:44 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 7
hi,
in this code errors are,
{
// create session for user which can be useful in throughout the appication
Server.Transfer("reservation.aspx");
}
hope it will be helpful
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
•
•
Join Date: May 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 7
hey,
glad that u got soln....please mark the thread as solved....
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
•
•
Join Date: May 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 1
Check out these links for the code, etc:
http://msdn.microsoft.com/en-us/library/ms178329.aspx
http://msdn.microsoft.com/en-us/library/d51ttbhx.aspx
http://www.asp101.com/Samples/login_aspx.asp
http://www.codeproject.com/KB/sessio...sionLogin.aspx
Remember--Google and MSDN are your best friends
http://msdn.microsoft.com/en-us/library/ms178329.aspx
http://msdn.microsoft.com/en-us/library/d51ttbhx.aspx
http://www.asp101.com/Samples/login_aspx.asp
http://www.codeproject.com/KB/sessio...sionLogin.aspx
Remember--Google and MSDN are your best friends
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Error message when running ASP login page (ASP)
Other Threads in the ASP.NET Forum
- Previous Thread: problem in updating the gridview
- Next Thread: session example in asp.net


Linear Mode