Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: hi!! Pin
Nekshan21-Feb-07 19:30
Nekshan21-Feb-07 19:30 
QuestionCalling a method from a form in another form [modified] Pin
motojojo20-Feb-07 23:56
motojojo20-Feb-07 23:56 
AnswerRe: Calling a method from a form in another form Pin
Colin Angus Mackay21-Feb-07 0:30
Colin Angus Mackay21-Feb-07 0:30 
AnswerRe: Calling a method from a form in another form Pin
Mark T.21-Feb-07 2:18
Mark T.21-Feb-07 2:18 
AnswerRe: Calling a method from a form in another form Pin
motojojo21-Feb-07 3:56
motojojo21-Feb-07 3:56 
QuestionAdd attribute to the http header of a request Pin
blackjack215020-Feb-07 23:55
blackjack215020-Feb-07 23:55 
AnswerRe: Add attribute to the http header of a request Pin
B.A21-Feb-07 1:30
B.A21-Feb-07 1:30 
Questionproblem in login page Pin
vijayashanthi20-Feb-07 23:43
vijayashanthi20-Feb-07 23:43 
hi all i am creating a login page and my problem was,
sp returns value for Num_of_User = 1 but the returnParam will always got a returnParamValue = 0..

what is wrong with this code...

this my code...


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

INSERT INTO NorthWindUsers
(UserName, Password)
VALUES ('sachin', 'tendulkar')

alter PROCEDURE sp_ValidateUser
(
@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



private void btnSubmit_Click(object sender, System.EventArgs e)
{
int maxLoginAttempts = (int)Session["MaxLoginAttempts"];

if (Session["LoginCount"].Equals(maxLoginAttempts))
{
Response.Redirect("WebForm1.aspx?reason=maxloginattempts");
}
if(Page.IsValid)
{
if(DBConnection(txtusername.Text.Trim(),txtPassword.Text.Trim()))
{
FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false);
}
else
{
lblMessage.Text = "Invalid Login Please Try again....";
}
}
}
private bool DBConnection(string txtUser,string txtPass)
{
//int a;
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connstr"]);
SqlCommand myCommand = new SqlCommand("sp_ValidateUser", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;

SqlParameter objParam1;
SqlParameter objParam2;
SqlParameter returnParam;

objParam1 = myCommand.Parameters.Add("@UserName", SqlDbType.VarChar);
objParam2 = myCommand.Parameters.Add("@Password",SqlDbType.VarChar);
returnParam = myCommand.Parameters.Add ("@Num_of_User",SqlDbType.Int);


objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
returnParam.Direction = ParameterDirection.ReturnValue;

objParam1.Value = "txtuser";
objParam2.Value = "txtPass";
//a = Convert.ToInt32(myCommand.Parameters["@num_of_User"].Value);
try
{
if(myConnection.State.Equals(ConnectionState.Closed))
{

myConnection.Open();
returnParam = myCommand.ExecuteNonQuery();

//Int32 rowCount = (Int32)catDA.InsertCommand.Parameters["@RowCount"].Value;


}

if((int)returnParam.Value < 1 )
{
int loginCount = (int)Session["LoginCount"];
loginCount += 1;
Session["LoginCount"] = loginCount;
lblMessage.Text = "Invalid Login";
return false;
}
else
{
myConnection.Close();
return true;
}

}
catch (Exception ex)
{
lblMessage2.Text = ex + "Error connecting to the database";
return false;
}
}
AnswerRe: problem in login page Pin
Colin Angus Mackay21-Feb-07 0:47
Colin Angus Mackay21-Feb-07 0:47 
Questionhow can encrypt a film Pin
B.A20-Feb-07 23:39
B.A20-Feb-07 23:39 
AnswerRe: how can encrypt a film Pin
Mark T.21-Feb-07 2:24
Mark T.21-Feb-07 2:24 
QuestionStopping a Thread Pin
nasambur20-Feb-07 23:22
nasambur20-Feb-07 23:22 
AnswerRe: Stopping a Thread Pin
nikneem200520-Feb-07 23:41
nikneem200520-Feb-07 23:41 
GeneralRe: Stopping a Thread Pin
nasambur21-Feb-07 0:48
nasambur21-Feb-07 0:48 
QuestionobjCompilerResults.Errors.Count Pin
nasambur20-Feb-07 23:18
nasambur20-Feb-07 23:18 
QuestionCompiler [modified] Pin
hiremath7120-Feb-07 22:59
hiremath7120-Feb-07 22:59 
QuestionCrystal Report Licence Pin
Banjo Ayorinde20-Feb-07 22:25
Banjo Ayorinde20-Feb-07 22:25 
QuestionAdding Items to combo box from a table field Pin
Banjo Ayorinde20-Feb-07 22:17
Banjo Ayorinde20-Feb-07 22:17 
AnswerRe: Adding Items to combo box from a table field Pin
Christian Graus20-Feb-07 23:09
protectorChristian Graus20-Feb-07 23:09 
AnswerRe: Adding Items to combo box from a table field Pin
Niiiissssshhhhhuuuuu20-Feb-07 23:12
Niiiissssshhhhhuuuuu20-Feb-07 23:12 
Questionhow can i send just one byte with serial port? Pin
Mir_As20-Feb-07 22:15
Mir_As20-Feb-07 22:15 
AnswerRe: how can i send just one byte with serial port? Pin
stancrm20-Feb-07 22:36
stancrm20-Feb-07 22:36 
QuestionLoading Report (Crystal Report) from my Application, after deployment. Pin
Banjo Ayorinde20-Feb-07 22:11
Banjo Ayorinde20-Feb-07 22:11 
QuestionProblem in loading form Urgent please Pin
NK720-Feb-07 20:47
NK720-Feb-07 20:47 
AnswerRe: Problem in loading form Urgent please Pin
NK720-Feb-07 20:48
NK720-Feb-07 20:48 

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.