calling a function returning boolean in another function

Blabeo2

New Member
I have the following function that I need to call in another function. I dont know how to do it?\[code\]private int IsValidUser(){ int result = 0; string strQuery = "Select Email From AUser Where Email = @Email And Password = @Password "; SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]); SqlCommand Cmd = new SqlCommand(strQuery, con); //Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue("@Email", txtEmail.Text); Cmd.Parameters.AddWithValue("@Password", txtPassword.Text); con.Open(); result = (int)Cmd.ExecuteScalar(); if (result > 0) { //Session["SessionEmail"] = txtEmail.Text; Session[General.S_USEREMAIL] = txtEmail.Text; Response.Redirect("~/frmMyAccountMyProfile.aspx"); } else { Literal1.Text = "Invalid Email/Password!"; }}\[/code\]I am trying to call it as below on button click event.\[code\]protected void btnSignIn_Click(object sender, EventArgs e){ // Authenticate User bool blnValidUser = false; IsValidUser(); blnValidUser = Convert.ToBoolean(IsValidUser().result.Value); if (blnValidUser) { // on Success - If remember me > Save to cookies //SaveUserDetailsToCookie(); } else { // on Failure - Show error msg }}\[/code\]
 
Back
Top