User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 401,425 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 2,906 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 C# advertiser: Programming Forums
Views: 91100 | Replies: 59
Reply
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 26
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Simple ASP.Net Login Page using C#

  #41  
Oct 31st, 2006
Microsoft.NET\Framework\v2.0.50727\

This is the reason, you are using this code which is for ASP.NET 1.1 and NOT ASP.NET 2.0. There are some significant differences between 1.1 and 2.0 framework that makes this code non-functional.

So if you want to use 2.0, you will have to debug and modify the code accordingly (I haven't had a free moment to post the 2.0 version of this code yet-- actually 2.0 has many things built in that streamline this). Recommend you check out http://www.asp.net/getstarted/default.aspx?tabid=61

For great video demos on creating a fully usable login and portal site.

Or if you are set on using 1.1, you will have to switch your default framework to 1.1 in IIS msc tool in windows.

Hope this helps
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Oct 2006
Posts: 2
Reputation: phebe is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
phebe phebe is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #42  
Oct 31st, 2006
Thank You very much
Reply With Quote  
Join Date: Oct 2006
Location: Home
Posts: 10
Reputation: GeniXmeN is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
GeniXmeN's Avatar
GeniXmeN GeniXmeN is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #43  
Nov 1st, 2006
Thanks a lot Paladine but when i have make like you have write to me and have try something else i always get this error:
'Login1.WebForm1.test(string, string)': not all code paths return a value

the function is:
privatebool test(string txtUser,string txtPassword)
{
OleDbConnection myConn = new OleDbConnection(ConfigurationSettings.AppSettings["strCon"]);
OleDbCommand myCmd = new OleDbCommand("proverka",myConn);
myCmd.CommandType = CommandType.StoredProcedure;
OleDbParameter objParam1,objParam2;
//OleDbParameter returnParam;
objParam1 = myCmd.Parameters.Add("@UserName",OleDbType.Char);
objParam2 = myCmd.Parameters.Add("@Password",OleDbType.Char);
//returnParam = myCmd.Parameters.Add("@ID",OleDbType.Integer);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
//returnParam.Direction = ParameterDirection.ReturnValue;
objParam1.Value = txtUser;
objParam2.Value = txtPassword;
 
try
{
if(myConn.State == ConnectionState.Closed)
{
myConn.Open();
//myCmd.ExecuteNonQuery();
}
OleDbDataReader objReader;
objReader = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
while(objReader.Read())
{
if((bool)(objReader.GetValue(0)) == false)
{
Label1.Text="Inavlid Login!";
return false;
}
else
{
objReader.Close();
return true;
}
}
}
catch(Exception ex)
{
Label2.Text = ex + "Error connecting to the DB!";
return false;
}
}
Last edited by Paladine : Nov 1st, 2006 at 6:48 pm. Reason: code blocks!
Reply With Quote  
Join Date: Oct 2006
Location: Home
Posts: 10
Reputation: GeniXmeN is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
GeniXmeN's Avatar
GeniXmeN GeniXmeN is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #44  
Nov 1st, 2006
I have and another question?

How to make when login is sucesiful and will open the page default.aspx to show me for example in textbox or label the first name and second name of the user normaly if in the DB we have information about that.
For example "Welcome John Jonson"
Reply With Quote  
Join Date: Feb 2007
Posts: 3
Reputation: kumarvp is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kumarvp kumarvp is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #45  
Feb 15th, 2007
hi! i was tested your code but i got an error..
i thing the error is in stored procedure...
pls send me the coding for stored procedure and table..
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 26
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Simple ASP.Net Login Page using C#

  #46  
Feb 16th, 2007
Originally Posted by GeniXmeN View Post
Thanks a lot Paladine but when i have make like you have write to me and have try something else i always get this error:
'Login1.WebForm1.test(string, string)': not all code paths return a value

the function is:
privatebool test(string txtUser,string txtPassword)
{
OleDbConnection myConn = new OleDbConnection(ConfigurationSettings.AppSettings["strCon"]);
OleDbCommand myCmd = new OleDbCommand("proverka",myConn);
myCmd.CommandType = CommandType.StoredProcedure;
OleDbParameter objParam1,objParam2;
//OleDbParameter returnParam;
objParam1 = myCmd.Parameters.Add("@UserName",OleDbType.Char);
objParam2 = myCmd.Parameters.Add("@Password",OleDbType.Char);
//returnParam = myCmd.Parameters.Add("@ID",OleDbType.Integer);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
//returnParam.Direction = ParameterDirection.ReturnValue;
objParam1.Value = txtUser;
objParam2.Value = txtPassword;
 
try
{
if(myConn.State == ConnectionState.Closed)
{
myConn.Open();
//myCmd.ExecuteNonQuery();
}
OleDbDataReader objReader;
objReader = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
while(objReader.Read())
{
if((bool)(objReader.GetValue(0)) == false)
{
Label1.Text="Inavlid Login!";
return false;
}
else
{
objReader.Close();
return true;
}
}
}
catch(Exception ex)
{
Label2.Text = ex + "Error connecting to the DB!";
return false;
}
}


Your code with the brackets located above have me a little puzzled. Be sure you can go through each logic path and have a return value!
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 26
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Simple ASP.Net Login Page using C#

  #47  
Feb 16th, 2007
Originally Posted by kumarvp View Post
hi! i was tested your code but i got an error..
i thing the error is in stored procedure...
pls send me the coding for stored procedure and table..


This is for ASP.NET 1.0 and 1.1 only, not 2.0 just as an FYI

Table
         CREATE TABLE NorthWindUsers 
             (UserID INT IDENTITY(1,1) NOT NULL,
              UserName VARCHAR(50) NOT NULL,
              Password VARCHAR(50) NOT NULL)

Stored Procedure in SQL 2000
         CREATE PROCEDURE sp_ValidateUser /* How it would appear in QUERY ANALYZER */
             (
                 @UserName VARCHAR(50) = NULL,
                 @Password VARCHAR(50) = NULL,
                 @Num_of_User INT = 0
             )
         AS
             SET @Num_of_User = (SELECT COUNT(*) AS Num_of_User
             FROM NorthWindUsers
             WHERE UserName = @UserName AND Password = @Password)
RETURN  @Num_of_User

Hope this helps

Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Feb 2007
Posts: 3
Reputation: kumarvp is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kumarvp kumarvp is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #48  
Feb 16th, 2007
hi paladine! thanks for ur reply..
my problem was, stored procedure always returns 0 only..
so i got invalid login name only....
Reply With Quote  
Join Date: Feb 2007
Posts: 1
Reputation: seshuv is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
seshuv seshuv is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #49  
Feb 24th, 2007
Web.Config
[code]
]
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="strConn" value="Network Library=DBMSSOCN;Data Source=192.168.0.100,1433;database=Northwind;User id=;Password=;"/>
</appSettings>
<system.web>

<!-- DYNAMIC DEBUG COMPILATION
...


Me in a learner, i just copied and tried...im getting an error near
"strConn"..? what i must add there... may i know in a brief way... this is the one error im getting when im trying to run program..

Seshu
Reply With Quote  
Join Date: Feb 2007
Posts: 1
Reputation: maridhasm is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
maridhasm maridhasm is offline Offline
Newbie Poster

Re: Simple ASP.Net Login Page using C#

  #50  
Feb 24th, 2007
hi
this is dos here,
your job doing great, still i haning a course .net in c#. now what i need from your guys, just give simple console application mini project or ideas for that relative environment. than you.
Reply With Quote  
Reply

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

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

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