943,949 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 333322
  • C# RSS
You are currently viewing page 5 of this multi-page discussion thread; Jump to the first page
Oct 31st, 2006
0

Re: Simple ASP.Net Login Page using C#

Quote ...
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
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Oct 31st, 2006
0

Re: Simple ASP.Net Login Page using C#

Thank You very much
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phebe is offline Offline
2 posts
since Oct 2006
Nov 1st, 2006
0

Re: Simple ASP.Net Login Page using C#

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 7:48 pm. Reason: code blocks!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
GeniXmeN is offline Offline
10 posts
since Oct 2006
Nov 1st, 2006
0

Re: Simple ASP.Net Login Page using C#

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"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
GeniXmeN is offline Offline
10 posts
since Oct 2006
Feb 15th, 2007
0

Re: Simple ASP.Net Login Page using C#

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..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kumarvp is offline Offline
3 posts
since Feb 2007
Feb 16th, 2007
0

Re: Simple ASP.Net Login Page using C#

Click to Expand / Collapse  Quote originally posted by GeniXmeN ...
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!
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Feb 16th, 2007
0

Re: Simple ASP.Net Login Page using C#

Click to Expand / Collapse  Quote originally posted by kumarvp ...
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

Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Feb 16th, 2007
0

Re: Simple ASP.Net Login Page using C#

hi paladine! thanks for ur reply..
my problem was, stored procedure always returns 0 only..
so i got invalid login name only....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kumarvp is offline Offline
3 posts
since Feb 2007
Feb 24th, 2007
0

Re: Simple ASP.Net Login Page using C#

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
seshuv is offline Offline
1 posts
since Feb 2007
Feb 24th, 2007
0

Re: Simple ASP.Net Login Page using C#

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maridhasm is offline Offline
1 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C# Forum Timeline: how to convert words to numerals
Next Thread in C# Forum Timeline: Login Form Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC