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?
Loading

Ashley Argile97 reputationPosted Oct 24, 2008, 1:17 AM EDT
string command = "AuthPlayer"; // Removed exec from this line
SqlCommand Sql = new SqlCommand(command, MSSQL);
Sql.CommandType = CommandType.StoredProcedure; // Add this line
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;
Hope this helps
Regards
Ashley.
Ernst5 reputationPosted Oct 24, 2008, 10:51 AM EDT
Ashley Argile97 reputationPosted Oct 25, 2008, 9:08 AM EDT
Regards
Ashley