Ernst

Ernst

  • NA
  • 3
  • 0

Sql Parameters mysteriously disappear

Oct 23 2008 6:11 PM
Hey,

I have a little bit of a problem with my project. When I try to use SQL parameters in the way C# intended them, they don't work

In the following code, I try to get the parameters in, however, it hangs on "SqlException: Required parameter @Name was not supplied".

string command = "exec AuthPlayer";
            SqlCommand Sql = new SqlCommand(command, MSSQL);
            MSSQL.Open();
            Sql.Parameters.AddWithValue("@Name", Name);
            Sql.Parameters.AddWithValue("@Pass", DoSha1(Pass));

            int PlayerID;
            try
            {
                PlayerID = (int)Sql.ExecuteScalar();
            }
            catch (Exception x)
            {
                MSSQL.Close();
                throw x;
            }

            MSSQL.Close();
            return PlayerID;


Does anyone know what my SQL server is smoking?

Answers (3)