| | |
Simple ASP.Net Login Page using C#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
Microsoft.NET\Framework\v2.0.50727\
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
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 7: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; } }
•
•
•
•
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..
Table
CREATE TABLE NorthWindUsers (UserID INT IDENTITY(1,1) NOT NULL, UserName VARCHAR(50) NOT NULL, Password VARCHAR(50) NOT NULL)
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
•
•
Join Date: Feb 2007
Posts: 1
Reputation:
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
![]() |
Similar Threads
- 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: C# online resources, help and advice?
- Next Thread: DataGridView with List In Object to Display
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml





