3
Answers

Sql Parameters mysteriously disappear

Ernst

Ernst

16y
4.4k
1
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)