•
•
•
•
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
![]() |
•
•
•
•
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
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
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:
'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!
•
•
•
•
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
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
•
•
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
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: Feb 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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
[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
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: Adding a new row in a Datagrid ???????????
- Next Thread: Adding custom rows at runtime from database


Linear Mode