S
snatch_this
Hi, I'm getting an error "error converting data type varchar to int",
while trying to execute a stored procedure. Which is weird, as I don't
have any int type variables anywhere in this piece of code. Here's the
sproc:
CREATE PROCEDURE [dbo].[spAccountLogin]
@accountName varchar(50),
@accountPswd varchar(50),
@accountType varchar(20) OUTPUT
AS
SELECT @accountType = accountType FROM [dbAccounts] WHERE accountName =
@accountName AND accountPswd = @accountPswd;
And here's the c# code:
01 myConnection.Open();
02 myCommand = new SqlCommand("spAccountLogin", myConnection);
03 myCommand.CommandType = CommandType.StoredProcedure;
04 myParameter = myCommand.Parameters.AddWithValue("@accountName",
SqlDbType.VarChar);
05 myParameter.Value = strLogin;
06 myParameter = myCommand.Parameters.AddWithValue("@accountPswd",
SqlDbType.VarChar);
07 myParameter.Value = strPassword;
08 myParameter = myCommand.Parameters.AddWithValue("@accountType",
SqlDbType.VarChar);
09 myParameter.Direction = ParameterDirection.Output;
10 myCommand.ExecuteNonQuery();
11 strUserRole = myCommand.Parameters["@accountType"].Value.ToString();
The error occurs at line 10.
I'm not sure if it makes any difference, but I'm using ASP.NET 2.0.
I would appreciate any suggestions!
while trying to execute a stored procedure. Which is weird, as I don't
have any int type variables anywhere in this piece of code. Here's the
sproc:
CREATE PROCEDURE [dbo].[spAccountLogin]
@accountName varchar(50),
@accountPswd varchar(50),
@accountType varchar(20) OUTPUT
AS
SELECT @accountType = accountType FROM [dbAccounts] WHERE accountName =
@accountName AND accountPswd = @accountPswd;
And here's the c# code:
01 myConnection.Open();
02 myCommand = new SqlCommand("spAccountLogin", myConnection);
03 myCommand.CommandType = CommandType.StoredProcedure;
04 myParameter = myCommand.Parameters.AddWithValue("@accountName",
SqlDbType.VarChar);
05 myParameter.Value = strLogin;
06 myParameter = myCommand.Parameters.AddWithValue("@accountPswd",
SqlDbType.VarChar);
07 myParameter.Value = strPassword;
08 myParameter = myCommand.Parameters.AddWithValue("@accountType",
SqlDbType.VarChar);
09 myParameter.Direction = ParameterDirection.Output;
10 myCommand.ExecuteNonQuery();
11 strUserRole = myCommand.Parameters["@accountType"].Value.ToString();
The error occurs at line 10.
I'm not sure if it makes any difference, but I'm using ASP.NET 2.0.
I would appreciate any suggestions!