Input string was not in a correct format.

D

Daniel Groh

I have this method that returns a user:

SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "SP_Login";

SqlParameter paramEmail = new SqlParameter("@Email",SqlDbType.VarChar,60);
paramEmail.Direction = ParameterDirection.Input;
paramEmail.Value = strEmail.Trim();
sqlCmd.Parameters.Add(paramEmail);

SqlParameter paramPassword = new SqlParameter("@Password",SqlDbType.VarChar,100);
paramPassword .Direction = ParameterDirection.Input;
paramPassword .Value = strPassword.Trim();
sqlCmd.Parameters.Add(paramPassword );

sqlCmd.Connection = objConn.SQLConn;
SqlDataReader drUser = sqlCmd.ExecuteReader();
return (string) drUser[0]

BUT, it's going to the catch and throwing this error: Input string was not in a correct format.

The procedure is ok, I'm running in QueryAnalyser and everything is working, but in my application...not!

Could someone please help me ?

Thanks in Advance
 
C

Cordell Lawrence

Could you post a dump of the exception ( the entire call stack ie. exception.ToString() )
I have this method that returns a user:

SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "SP_Login";

SqlParameter paramEmail = new SqlParameter("@Email",SqlDbType.VarChar,60);
paramEmail.Direction = ParameterDirection.Input;
paramEmail.Value = strEmail.Trim();
sqlCmd.Parameters.Add(paramEmail);

SqlParameter paramPassword = new SqlParameter("@Password",SqlDbType.VarChar,100);
paramPassword .Direction = ParameterDirection.Input;
paramPassword .Value = strPassword.Trim();
sqlCmd.Parameters.Add(paramPassword );

sqlCmd.Connection = objConn.SQLConn;
SqlDataReader drUser = sqlCmd.ExecuteReader();
return (string) drUser[0]

BUT, it's going to the catch and throwing this error: Input string was not in a correct format.

The procedure is ok, I'm running in QueryAnalyser and everything is working, but in my application...not!

Could someone please help me ?

Thanks in Advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top