Click here to Skip to main content
15,887,952 members
Home / Discussions / C#
   

C#

 
AnswerRe: License Key Generation Tool Pin
RWBitters27-Nov-09 15:11
RWBitters27-Nov-09 15:11 
QuestionDatabase retrieving problem Pin
Nishad8517-Sep-07 18:12
Nishad8517-Sep-07 18:12 
QuestionProblem with SQL Update using Variables in C# [modified] Pin
ba1959nh17-Sep-07 16:29
ba1959nh17-Sep-07 16:29 
AnswerRe: Problem with SQL Update using Variables in C# Pin
PIEBALDconsult17-Sep-07 18:34
mvePIEBALDconsult17-Sep-07 18:34 
AnswerRe: Problem with SQL Update using Variables in C# Pin
ba1959nh18-Sep-07 2:58
ba1959nh18-Sep-07 2:58 
GeneralRe: Problem with SQL Update using Variables in C# Pin
PIEBALDconsult18-Sep-07 5:03
mvePIEBALDconsult18-Sep-07 5:03 
QuestionQuestion on checkedlistbox if statement Pin
falles0117-Sep-07 15:27
falles0117-Sep-07 15:27 
QuestionLogon with UserName and Password Pin
T4AMD17-Sep-07 12:15
T4AMD17-Sep-07 12:15 
The values entered in the UserName TextBox and Password TextBox are compared to the values in the database using the StoredProcedure. And based on that a user is given access to FileManager.aspx or shown an AccessDenied.aspx page. But it does not work that way? I get access to FileManager.aspx page no matter what UserName and Password I put in. Can somebody please tell me what should be the correct code in the Try..Catch method. Cuz that's where my code is wrong. My StoredProcedure works fine. Thanks
protected void btnLogOn_Click(object sender, EventArgs e)
{
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
try
{
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
}
catch
{
}
finally
{
Response.Redirect("FileManager.aspx");
sqlconSource.Close();
}

And this is my Stored Procedure:
ALTER PROC [dbo].[LogOn]
@UserName varchar(40),
@Password varchar(10)
AS
begin
if exists(select * from UserInformation where UserName = @UserName AND Password = @Password)
begin
select 1 returnflag --UserName is found
end
else
begin
select 0 returnflag--UserName not found
end
end
RETURN

AnswerRe: Logon with UserName and Password Pin
ChrisKo17-Sep-07 12:33
ChrisKo17-Sep-07 12:33 
QuestionRe: Logon with UserName and Password Pin
T4AMD17-Sep-07 12:42
T4AMD17-Sep-07 12:42 
AnswerRe: Logon with UserName and Password Pin
ChrisKo17-Sep-07 12:50
ChrisKo17-Sep-07 12:50 
AnswerRe: Logon with UserName and Password Pin
PIEBALDconsult17-Sep-07 14:01
mvePIEBALDconsult17-Sep-07 14:01 
QuestionConsole application keypress Pin
ballzinator17-Sep-07 11:50
ballzinator17-Sep-07 11:50 
AnswerRe: Console application keypress Pin
ChrisKo17-Sep-07 12:27
ChrisKo17-Sep-07 12:27 
GeneralRe: Console application keypress Pin
ballzinator18-Sep-07 3:27
ballzinator18-Sep-07 3:27 
GeneralRe: Console application keypress Pin
Big Daddy Farang18-Sep-07 8:22
Big Daddy Farang18-Sep-07 8:22 
Questionwhat is better c# or vb.net ?? Pin
sofy200817-Sep-07 11:49
sofy200817-Sep-07 11:49 
AnswerRe: what is better c# or vb.net ?? Pin
Matthew Cuba17-Sep-07 12:42
Matthew Cuba17-Sep-07 12:42 
AnswerRe: what is better c# or vb.net ?? Pin
Patrick Etc.17-Sep-07 13:33
Patrick Etc.17-Sep-07 13:33 
GeneralRe: what is better c# or vb.net ?? Pin
PIEBALDconsult17-Sep-07 13:58
mvePIEBALDconsult17-Sep-07 13:58 
GeneralRe: what is better c# or vb.net ?? Pin
Luc Pattyn17-Sep-07 14:41
sitebuilderLuc Pattyn17-Sep-07 14:41 
AnswerRe: what is better c# or vb.net ?? Pin
BoneSoft17-Sep-07 17:50
BoneSoft17-Sep-07 17:50 
GeneralRe: what is better c# or vb.net ?? Pin
Big Daddy Farang18-Sep-07 8:30
Big Daddy Farang18-Sep-07 8:30 
GeneralRe: what is better c# or vb.net ?? Pin
BoneSoft18-Sep-07 8:51
BoneSoft18-Sep-07 8:51 
AnswerRe: what is better c# or vb.net ?? Pin
PIEBALDconsult17-Sep-07 18:15
mvePIEBALDconsult17-Sep-07 18:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.