Timeout error

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 27-Apr-2009 03:02:08   

Hi, i am getting the error below. i have no idea why it occurs. everthing seems pretty good to me. here is what i have and at the bottom is the error i am getting.

Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "UpdateUser"); try {

        UpdateStaff(userTitleId, firstName, middleName, lastName, nickName, password, eMail, homePhone, photo, userId, trans);

        UpdateAddress(address1, address2, city, state, zipCode, userId, trans);

        UpdateStaffHistory(academicYearId, departmentId, userId, trans);

                trans.Commit();
                return userId;
            }
            catch (Exception)
            {
                trans.Rollback();
                throw;
            }

the updatestaff part of this code runs fine. it jumps in the updateaddress part in where it finds the address of the user using the userid and updates it. this is where i am getting the error.

here is my updateaddress: private static void UpdateAddress(string address1, string address2, string city, string state, string zipCode, int userId, Transaction trans) { AddressEntity address = UserGuiHelper.GetUserAddress(userId); // add it to the transaction trans.Add(address); address.AddressLine1 = address1; address.AddressLine2 = address2; address.City = city; address.State = state; address.PostalCode = zipCode; // update user address and get its addressid address.Save(); }

and getuseraddress is: public static AddressEntity GetUserAddress(int userId) { UserEntity user = GetUser(userId); ---> this line gives the error AddressEntity toReturn = user.Address; return toReturn; }

and my getuser is: public static UserEntity GetUser(int userID) { UserEntity user = new UserEntity(userID); return user.IsNew ? null : user; }

is it something about the transaction? using ver 2.6, self servicing, sql express 2008 .net 3.5

Server Error in '/00-GUI' Application.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Source Error:

Line 1742: IDao dao = this.CreateDAOInstance(); Line 1743: base.Fields[(int)UserFieldIndex.UserId].ForcedCurrentValueWrite(userId); Line 1744: dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse, excludedIncludedFields); Line 1745: return (base.Fields.State == EntityState.Fetched); Line 1746: }

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Apr-2009 04:07:44   

Timeouts will generally be caused by something in the database that you are trying to modify being locked by another transaction. You could update the CommandTimeout property of the DataAccessAdapter as described here but this is rarely the solution unless you genuinely have a long running query somewhere else which is locking the data.

Do you have any other users/application etc running against the same database - you need to investigate what is causing the lock.

Also please these suggestions: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11367

What database and database version are you using? What llblgen runtime library version are you using?

David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 27-Apr-2009 04:36:47   

Hi, i think i found the problem. updateuser gets the userentity in the transaction, then update address tries to get the same user entity to reach at his address but it cant because its locked. is there a way to read the locked data like a readonly entity?

i am using llblgen 2.6. self servicing, sql express 2008, c# .net 3.5

daelmo wrote:

Timeouts will generally be caused by something in the database that you are trying to modify being locked by another transaction. You could update the CommandTimeout property of the DataAccessAdapter as described here but this is rarely the solution unless you genuinely have a long running query somewhere else which is locking the data.

Do you have any other users/application etc running against the same database - you need to investigate what is causing the lock.

Also please these suggestions: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11367

What database and database version are you using? What llblgen runtime library version are you using?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 27-Apr-2009 08:10:54   

public static AddressEntity GetUserAddress(int userId) { UserEntity user = GetUser(userId); ---> this line gives the error AddressEntity toReturn = user.Address; return toReturn; }

Ib the GetUserAddress, don't fetch the user, just fetch the AddressEntity using a filter on the UserId.

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 27-Apr-2009 15:57:40   

i would do that but the addressid is kept in user entity. its not that the address entity keeps the userid.

Walaa wrote:

public static AddressEntity GetUserAddress(int userId) { UserEntity user = GetUser(userId); ---> this line gives the error AddressEntity toReturn = user.Address; return toReturn; }

Ib the GetUserAddress, don't fetch the user, just fetch the AddressEntity using a filter on the UserId.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 27-Apr-2009 16:18:40   

Then switch the process, save the adress first, then using the returned AddressId, you can save the user.

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 27-Apr-2009 16:22:36   

simple_smile you are right. i solved it by providing the user entity as an input param to my updateaddress method but your solutions is a lot simpler.

thank you -shane

Walaa wrote:

Then switch the process, save the adress first, then using the returned AddressId, you can save the user.