Click here to Skip to main content
15,898,374 members

Comments by er.harmanpreetsingh (Top 7 by date)

er.harmanpreetsingh 1-Oct-12 8:37am View    
This is my store proc..
and i think the name provided is right...
My store proc is this..

[dbo].[p_Testportal_Login]

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



Create Proc [dbo].[p_Testportal_Login]
(
@Name VarChar(50),
@Password varChar(50),
@OutRes int OUTPUT
)
AS
set @OutRes = (SELECT count(*) FROM dbo.HRIS_Employee
WHERE Name = @Name And Password = @Password)
if(@OutRes = 1)

begin
set @OutRes = 1--Login is Correct
end
else
begin
set @OutRes = 0 --Bad login
end
er.harmanpreetsingh 1-Oct-12 8:21am View    
Thank you dear 4 your great suuport..
I debug the programme.. it throws the exception.. {"Invalid object name 'dbo.HRIS_Employee'."}..here hris_Employee is my table name.

and my code is..
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace IVPTestPortal
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtUsername.Focus();
}

//private bool Authenticate(string userName, string password, string domain)
//{
// bool authentic = false;
// try
// {

// authentic = true;
// }
// catch (Exception ex)
// {
// vldAutheticate.ErrorMessage = "Invalid username and password. Contact your administrater !";
// }
// return authentic;
//}
//Code

public int Validate_Login(String Username, String Password)
{
//SqlConnection con = new SqlConnection(@"User id=sa;Password=123456;Server=LOVE-PC\YES;Database=HRIS_Employee");
SqlConnection con = null;
con = DABase.OpenConnection();
// con.Open();
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.CommandText = "[dbo].[p_Testportal_Login]";
cmdselect.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = Username;
cmdselect.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = Password;
cmdselect.Parameters.Add("@OutRes", SqlDbType.Int, 4);
cmdselect.Parameters["@OutRes"].Direction = ParameterDirection.Output;
cmdselect.Connection = con;
int Results = 0;
try
{
//con.Open();
cmdselect.ExecuteNonQuery();
Results = (int)cmdselect.Parameters["@OutRes"].Value;
}
catch (SqlException ex)
{
lblMessage.Text = ex.Message;
}
finally
{
cmdselect.Dispose();
if (con != null)
{
con.Close();
}
}
return Results;
}

protected void btnLogin_Click(object sender, EventArgs e)
{


int Results = 0;

if (txtUsername.Text != null && txtPassword.Text != null)
{

Results = Validate_Login(txtUsername.Text, txtPassword.Text);

if (Results == 1)
{
Response.Redirect("TakeTest.aspx");
//lblMessage.Text = "Login is Good, Send the User to another page or enable controls";

}

else
{

lblMessage.Text = "Invalid Login";

lblMessage.ForeColor = System.Drawing.Color.Red;

}
}

else
{

lblMessage.Text = "Please make sure that the username and the password is Correct";

}

}
//code




//protected void btnLogin_Click(object sender, EventArgs e)
//{
// SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
// con.Open();
// SqlCommand cmd = new SqlCommand("select * from HRIS_Employee where Username=@Name and Password=@Password", con);
// cmd.Parame
er.harmanpreetsingh 1-Oct-12 3:26am View    
I tried this code but it always shows invalid login
er.harmanpreetsingh 8-Jan-12 12:31pm View    
It is just a drag and drop method to create a browser how could i see the design code behind that form..
er.harmanpreetsingh 8-Jan-12 12:27pm View    
I got it... It perform all the functionality of webbrowser.
But I want to make a executable (.exe) file of it , But it runs only as a form or page. How could I make (.exe) file so that i can run it on any machine.