?
Solved

Sql server timeout error when updating user profile

Posted on 2010-09-10
6
Medium Priority
?
672 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

770 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