I found the solution for my problems and it is that:
first problem:
The connection was not closed. The connection's current state is open.
solution:
I used try....catch...finally:
try
{
connection.Open();
TopicsNum = Convert.ToInt32(topicCommand.ExecuteScalar());
connection.Close();
}
catch
{
}
finally
{
connection.close();
}
second problem:
Procedure uspNumOfTopicInTable has no parameters and arguments were supplied.
solution:
I used this code:
topicCommand.Parameters.clear();
the last problem is custom problem that related to my code and i solved it according to my case.
Thanks every body
bye