ActionProcedure is timing out

Posts   
 
    
JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 19-Jun-2008 01:23:51   

I am using an adapter

using (DataAccessAdapter adapter = new DataAccessAdapter()) {

I create a new entity and save it ... no problem.

I then call an actionProcedure and it times out. }

I have read where I can set adapter.CommandTimeOut = 120; and I do set this after the saveEntity and immediately prior to calling the actionProcedure

and in debugging the code I do see that the adaptor commandtimeout is set to 120 prior to executing the actionProcedure. However, the procedure times out after 30 seconds.

Am I missing something?

Here is a little more info SQL Server 2005 Dev Edition running on a laptop LLBLGen v2.x ASP.Net 2.0 / VS 2005

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Jun-2008 11:08:49   

Are you sure you don't need to set the connection timeout? Please check this thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5301

Please try to call this SP manually from the database tools, to see if it timeout or see how long it takes it to execute.

JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 19-Jun-2008 11:57:30   

Saw the other thread, not sure what you want me to take from it ... I have no problem connecting to the database, it is the command that is timing out.

The manual execute takes 35 seconds in Sql Management tools.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Jun-2008 12:22:43   

Just to make sure, when you call the actionStoredProcedure, would you be able to see the SP call in the SQL Profiler?

I have a feeling the application is facing problems finding or accessing the specified SP.

JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 19-Jun-2008 12:25:13   

the stored procedure is getting called ... as this SProc updates another table and it is getting through about 90 % of the list of things to process.

JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 19-Jun-2008 14:37:57   

I have taken the call to the Sproc out of the Using ( DataAccessAdaptor...){} and made it a using a separate adaptor and it is now working. Any thoughts on why this is needed?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Jun-2008 15:20:14   

No idea. Would you please the exact non-working real code?

arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 19-Jun-2008 15:48:21   

Any thoughts on why this is needed?

Have you checked for blocking in the database?

JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 19-Jun-2008 17:08:37   

Here is a copy of the code ...

using (DataAccessAdapter adapter = new DataAccessAdapter()) { InvoiceEntity Invoice = new InvoiceEntity(); Invoice.IsNew = true; Invoice.Locked = 0; VSIMSMasterPage daMasterPage = (VSIMSMasterPage)this.Master; Invoice.YearId = YearID; Invoice.orgId = daMasterPage.CurUserOrg.OrgId; Invoice.InvoiceMonth = month; Invoice.InvoiceType = InvoiceType.District.ToString(); Invoice.Status = InvoiceStatus.New.ToString(); Invoice.CreatedBy = Page.User.Identity.Name; Invoice.ModifiedBy = null; adapter.SaveEntity(Invoice, true);

adapter.CommandTimeOut = 120;
ActionProcedures.InvoiceDataCollection(Invoice.InvoiceId);

}

and no there is no blocking issue within the db ...

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 19-Jun-2008 20:18:29   

I believe the command timeout can not be changed once the connection has been opened.

It gets opened when you do the SaveEntity. Try moving the CommandTimeout to the beginning, or at least before calling any methods on the adapter.

Since it is just a timeout, it shouldn't affect the save at all.


using (DataAccessAdapter adapter = new DataAccessAdapter()) {
    adapter.CommandTimeOut = 120;

    InvoiceEntity Invoice = new InvoiceEntity();
    Invoice.IsNew = true;
    Invoice.Locked = 0;
    VSIMSMasterPage daMasterPage = (VSIMSMasterPage)this.Master;
    Invoice.YearId = YearID;
    Invoice.orgId = daMasterPage.CurUserOrg.OrgId;
    Invoice.InvoiceMonth = month;
    Invoice.InvoiceType = InvoiceType.District.ToString();
    Invoice.Status = InvoiceStatus.New.ToString();
    Invoice.CreatedBy = Page.User.Identity.Name;
    Invoice.ModifiedBy = null;
    adapter.SaveEntity(Invoice, true);

    ActionProcedures.InvoiceDataCollection(Invoice.InvoiceId);
}

JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 19-Jun-2008 20:45:22   

yup, thought about that as well and moved the change timeout to the top after the using ... same thing.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 20-Jun-2008 09:59:30   

Try to keep the connection open as follows.

using (DataAccessAdapter adapter = new DataAccessAdapter(true)) { adapter.CommandTimeOut = 120;

InvoiceEntity Invoice = new InvoiceEntity();
Invoice.IsNew = true;
Invoice.Locked = 0;
VSIMSMasterPage daMasterPage = (VSIMSMasterPage)this.Master;
Invoice.YearId = YearID;
Invoice.orgId = daMasterPage.CurUserOrg.OrgId;
Invoice.InvoiceMonth = month;
Invoice.InvoiceType = InvoiceType.District.ToString();
Invoice.Status = InvoiceStatus.New.ToString();
Invoice.CreatedBy = Page.User.Identity.Name;
Invoice.ModifiedBy = null;
adapter.SaveEntity(Invoice, true);

ActionProcedures.InvoiceDataCollection(Invoice.InvoiceId);

}

JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 20-Jun-2008 14:01:28   

nope ... same thing right at 30 seconds the sproc call is stopped.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jun-2008 16:51:24   

You have to use the overload of the proc call method which accepts an adapter simple_smile Otherwise it will create a new one and will of course use the default timeout. So set the timeout and then pass it to the overload:

using (DataAccessAdapter adapter = new DataAccessAdapter()) { adapter.CommandTimeOut = 120;

InvoiceEntity Invoice = new InvoiceEntity();
Invoice.IsNew = true;
Invoice.Locked = 0;
VSIMSMasterPage daMasterPage = (VSIMSMasterPage)this.Master;
Invoice.YearId = YearID;
Invoice.orgId = daMasterPage.CurUserOrg.OrgId;
Invoice.InvoiceMonth = month;
Invoice.InvoiceType = InvoiceType.District.ToString();
Invoice.Status = InvoiceStatus.New.ToString();
Invoice.CreatedBy = Page.User.Identity.Name;
Invoice.ModifiedBy = null;
adapter.SaveEntity(Invoice, true);

ActionProcedures.InvoiceDataCollection(Invoice.InvoiceId**, adapter**);

}

You can set the timeout whenever you like, it's not necessary to set it before the connection is opened, as this timeout is for commands, which are created on the fly. Setting it right after the using statement of course also uses this timeout for the SaveEntity call.

Frans Bouma | Lead developer LLBLGen Pro
JeffStone
User
Posts: 8
Joined: 19-Jun-2008
# Posted on: 20-Jun-2008 17:02:12   

shear genius ... that was it and it makes sense ... I very much appreciate everyone's help.