Code:
string strConn = ConfigurationSettings.AppSettings["strConnection"];
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
//Create an SQL Command object, and assign
SqlCommand cmd = new SqlCommand();
cmd.Connection=conn;
cmd.CommandText="spNewUser";
cmd.CommandType=CommandType.StoredProcedure;
//Create The Parameters
SqlParameter param;
//Add Coorperate Status
param = cmd.Parameters.Add("@blCooperate",SqlDbType.Bit);
param.Direction = ParameterDirection.Input;
param.Value = blUserType;
//Add Password
param = cmd.Parameters.Add("@strPassword",SqlDbType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = tbPassword;
//Add Number of Properties
param = cmd.Parameters.Add("@nProperties",SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = 0;
//Add First Name
param = cmd.Parameters.Add("@strFName",SqlDbType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = tbFName;
//Add Last Name
param = cmd.Parameters.Add("@strSName",SqlDbType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = tbFName;
cmd.ExecuteNonQuery();
When I run the above, I get the following Error Message in my browser
" System.InvalidCastException: Object must implement IConvertible"
The Highlighted line is the NonQuery line
I have never before had issues using sprocs, but this has got me confused.
Anyone know where to even start fixing this ?
Cheers,
K