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 ArgilePosted Oct 24, 2008, 5:17 AM
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.
Ashley ArgilePosted Oct 25, 2008, 1:08 PM
Regards
Ashley
ErnstPosted Oct 24, 2008, 2:51 PM