Tavousi
Tavousi

Reputation: 15446

Exception in use ExecuteScalar

I want to get a person from database in C# with ADO.net.

I use this command:

System.Data.Common.DbCommand command = DatabaseManager.Database.GetStoredProcCommand(proc_name, firstName);

and then

object personID = DatabaseManager.Database.ExecuteScalar(command);

When I click a button, these commands calls two times.

In the first time it is OK. But the second time, I get TimeOutException:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

I used command.Disposed(); and command.Connection.Close();. But these not resolve my problem.

Please help me how I can resolve this problem.

Upvotes: 0

Views: 748

Answers (1)

Fedor Hajdu
Fedor Hajdu

Reputation: 4695

It seems that some transaction is left open during your first execution of the procedure. This can be either by an error in your procedure or bad connection management in your application.

Upvotes: 1

Related Questions