i got error in login

Posted by reddysankark-13471 under ASP.NET on 10/17/2012 | Points: 10 | Views : 688 | Status : [Member] | Replies : 1
hi
i got error like this
Input string was not in a correct format.
my coding

login.aspx.cs

protected void Button1_Click(object sender, EventArgs e)
{
string username = TextBox1.Text;
string password = TextBox2.Text;
int status = FileUpload.AuthenticateUser(username, password);
if (status >= 1)
{
Response.Redirect("~/FileUpload/Home.aspx");
}
else
{
Response.Redirect("<alert>invalid user</alert>");
}
}
fileupload.cs

public static int AuthenticateUser(string username, string password)
{

SqlParameter[] p = new SqlParameter[] { new SqlParameter("@UName", username), new SqlParameter("@Password", password) };
return int.Parse(SqlHelper.ExecuteScalar(ConnectionString.GetConnectionString(), CommandType.StoredProcedure, "spAuthenticateUser", p).ToString());
}

stored procedure
ALTER procedure [dbo].[spAuthenticateUser]
(
@UName varchar(50),
@Password varchar(50)
)
AS
if exists(select Username from Image1 where Username=@UName)
begin
Select Username,Password from Image1 where [UserName]=@UName And [Password]=@Password
select 1
end
else
begin
select 0
end


my table
CREATE TABLE [dbo].[Image1](
[Id] [tinyint] IDENTITY(1,1) NOT NULL,
[ImageName] [varchar](50) NULL,
[ImageSize] [bigint] NULL,
[ImagePath] [varchar](50) NULL,
[Username] [varchar](50) NULL,
[Password] [varchar](50) NULL
)

sankarreddy


Responses

Posted by: Ranjeet_8 on: 10/18/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Write this code instead of Response.Redirect("<alert>invalid user</alert>");

Response.Write("<script>alert('invalid user')</script>");


reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response