Click here to Skip to main content
11,646,838 members (74,097 online)
Rate this: bad
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)
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
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
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.
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
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);
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
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
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
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)

  Print Answers RSS
0 510
1 Sergey Alexandrovich Kryukov 478
2 OriginalGriff 428
3 CPallini 334
4 F-ES Sitecore 309
0 OriginalGriff 1,253
1 994
2 DamithSL 896
3 Sergey Alexandrovich Kryukov 833
4 CPallini 720

Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2015
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