Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body,

I have problem when execute that code:
ado.net
using (SqlConnection con = new SqlConnection(connectionString))
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Loging";
            cmd.Parameters.AddWithValue("@UserName", username);
            cmd.Parameters.AddWithValue("@PassWord", password);
            con.Open();
            int x =Convert.ToInt32(cmd.ExecuteScalar());
            isAuthenticated = x == 1;
            
        }


It give me this message:
Input string was not in a correct format.


It marks on this part of code :
int x =Convert.ToInt32(cmd.ExecuteScalar());


?????????
Posted
Updated 18-Oct-10 11:25am
v3
Comments
Dalek Dave 18-Oct-10 17:25pm    
Edited for Code Block.

1 solution

I'd be willing to be that your cmd is returning something that is not compatible with the int type.

What is the return type on the stored proc? Create a variable, assign the result to that first. Then set a breakpoint and see what's returned.

Cheers.
 
Share this answer
 
Comments
MrLonely_2 18-Oct-10 17:33pm    
Thanks man i solved it.
The stored procedure that return string, and i change it to return integer
Thanks

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900