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
Reply |
Reply with attachment |
Alert Moderator