Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
protected void loginControl_Authenticate(object sender, AuthenticateEventArgs e)
    {
        Employee user = new Employee();
        user.EmployeeID = Convert.ToInt32(loginControl.UserName);
        user.Password = loginControl.Password;
        e.Authenticated = EmployeeDAO.authenticateEmployee(user);
 

 
        if (e.Authenticated)
        {
            Response.Redirect("DefaultSecure.aspx");
        }
    }
this is my code of inpun on user name and paswd but it showing Input string was not in a correct format this error.i ma not geting plz help
Posted 26-Dec-12 5:47am
Comments
ridoy at 26-Dec-12 11:52am
   
what is loginControl? where you initialize it?
Anele Ngqandu at 27-Dec-12 5:06am
   
what is the format of the EmployeeID?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Look at your code: there is only one place that can generate that error.
user.EmployeeID = Convert.ToInt32(loginControl.UserName);
From that, the clue is in the Property name: loginControl.UserName is unlikely to be a number, so the Convert.ToInt32 will throw an error.
 
I suspect you want a different property.
  Permalink  
Comments
Eknath Sonawane at 26-Dec-12 12:03pm
   
so which property will be suit over here
OriginalGriff at 26-Dec-12 14:10pm
   
Well that's up to you - you know what control you are using, not me! I'd suggest an integer one or perhaps a lookup from the name to the ID?
Bear in mind I can only see the seven lines of code you posted above...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This might helps you. Use
user.UserName  = loginControl.UserName;
instead of
user.EmployeeID = Convert.ToInt32(loginControl.UserName);
  Permalink  
Comments
Eknath Sonawane at 26-Dec-12 23:22pm
   
this is my function still this is not working
public static bool authenticateEmployee(Employee employee)
{
string query = "SELECT EmployeeID FROM Employee WHERE EmployeeID = @EmployeeID AND Password = @Password";
SqlCommand command = new SqlCommand(query);
command.Parameters.AddWithValue("@EmployeeID", employee.EmployeeID);
command.Parameters.AddWithValue("@Password", employee.Password);
DataTable dataTable = executeQuery(command);
 
if (dataTable.Rows.Count > 0)
return true;
 
return false;
}
Sheikh Muhammad Haris at 26-Dec-12 23:27pm
   
Do you have any username (Login ID) field in your database? Use it instead of EmployeeID. I am expecting EmployeeID to be the primary key of your table.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  user.EmployeeID = Convert.ToInt32(loginControl.UserName);
 
brother make sure that Employee has the prpoerty EmployeeID type of string?
 
command.Parameters.AddWithValue("@EmployeeID", employee.EmployeeID);
 
explain here first that what is data type of EmployeeID in your database?
also, what is the data type of EmployeeID in your object? then some one would guess, what's going on exactly
  Permalink  
Comments
Eknath Sonawane at 27-Dec-12 1:57am
   
Emplpyee having property EmployeeId of type Int
Eknath Sonawane at 27-Dec-12 1:58am
   
i am aslo chengit it to string but it didt rpl if u dnt mind will u please sned me ur emailid i will send u the project plz help
Faisalabadians at 27-Dec-12 2:06am
   
craze.programmer@gmail.com
Faisalabadians at 27-Dec-12 2:07am
   
also, database or database script would be required.
Eknath Sonawane at 27-Dec-12 5:13am
   
just check out your mail i have just send u that project
Faisalabadians at 27-Dec-12 7:07am
   
ok. i check

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100