Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sql server timeout error when updating user profile

Posted on 2010-09-10
6
Medium Priority
?
674 Views
Last Modified: 2012-05-10
Hello,

I have a LINQ recordset (of users and their username) that I want to loop through and update a user's profile value.  The profile information is based on the default asp.net membership tables.

The following is my code and the timeout error is happening on the userProfile.save() line
Dim dbRGT As New RegentSignsDataContext

        Dim myResults = From myTable In dbRGT.vw_USERS_GroupEmails

        For Each myRow In myResults
            ''The following line writes out to the OUTPUT window during Debug
            ''System.Diagnostics.Debug.Write(myRow.chrFullName.ToString + " = " + myRow.UserId.ToString)
            Dim userProfile As ProfileCommon = ProfileCommon.Create(myRow.UserName, True)
            userProfile.groupEmail = 1
            userProfile.Save()            
        Next

Open in new window


The specific error I am getting is:
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. I should add that if I take out the profile.save I can loop through the recordset and perform other functions with no problem.

Can anyone help me figure out why this error is happening.  All other connections to the SQL server are working and have never thrown a timeout error.  

I even tried adding this code into the function in desperation:
System.Data.SqlClient.SqlConnection.ClearAllPools()
but it did not help at all
0
Comment
Question by:jordanking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 9

Accepted Solution

by:
wellhole earned 2000 total points
ID: 33650520
Wherever your profilecommon executes the sql, you should set the command timeout to a value higher than the default.
0
 
LVL 1

Author Comment

by:jordanking
ID: 33650825
Thanks for the quick reply,

I changed my connection string in the web.config file which references a development database on a sql server 2008 express edition on the local computer where visual studio is running

the connection string is now:
   

This did not solve the problem.  I believe this changed the timeout to 30 seconds.  
0
 
LVL 9

Expert Comment

by:wellhole
ID: 33651104
I expect that the default timeout is 30 seconds. You should increase it to 900 and see if that fixes it.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:jordanking
ID: 33651187
I made that change but it did not work.  It did not wait 900 seconds and it threw the error same as before
0
 
LVL 9

Assisted Solution

by:wellhole
wellhole earned 2000 total points
ID: 33651201
Then, I hope your sql is formatted correctly such that it's not trying to wipe out the whole database in 1 shot.

Besides that, see if you can change this timeout for the COMMAND and not the connection.
0
 
LVL 1

Author Comment

by:jordanking
ID: 33651785
okay,

so i took out LINQ data altogether and tested my code with just one record and it worked.  So then I tried adding the following code right below the datacontext declaration:
dbRGT.CommandTimeout = 9000

however that did not extend the time at all, so i thought it must be something with how i am getting the users profile.  So i changed the way I get all the users and it works.  The commandtimeout was a valueable lesson for using LINQ and SQL datacontext commands, so thanks for pointing me in that direction.

My working code is now:
Dim chrUsername As String

        Dim muc As MembershipUserCollection
        muc = Membership.GetAllUsers()
        Dim mu As MembershipUser
        For Each mu In muc
            chrUsername = mu.UserName
            Dim userProfile As ProfileCommon = ProfileCommon.Create(chrUsername, True)
            userProfile.groupEmail = 1
            userProfile.Save()
            ''iRet = myEmail.GroupEmail(myRow.Email, myRow.chrFullName, myRow.UserId.ToString, guidEmail)
        Next

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question