[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

CLR stored procedure stops randomly(time out?) when run from client application.

Hello,

I have a clr stored procedure that inserts rows in a table. When run from sql server itself, the sp inserts every row correctly(about 6500 rows). When it is run from the client application, the sp stops at around 1500 rows inserted(about 30 seconds), which leads me to think that there's a timeout somewhere.

Any idea why it does that?

Thanks alot.
0
PatricePaquette
Asked:
PatricePaquette
  • 3
  • 2
  • 2
2 Solutions
 
Randy PetersonCommented:
The timeout is in your connection string.  Defaulted to 30 seconds.
0
 
60MXGCommented:
Try to set the time longer in your config file so it would be something like this.  Hope that help!

<settings>
       <add key="connectionToMyDB" value="server=192.168.1.50; database=myDataBase; uid=myId; pwd=myPassWord; Connection Lifetime=6000;">
</settings>
0
 
PatricePaquetteAuthor Commented:
From what I understand, the timeout for the connection is the time it waits until the connection is made. Since 1500 rows are are added, the connection has obviously been made and shouldn't timeout.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
Randy PetersonCommented:
The timeout happens if the response does not come back after a certain time.  On your insert, you don't get a response back until all rows are inserted. That is why you get the timeout, it thinks it lost connection to the server because it sent the command, but after 30 seconds, it never got a response back so it timed out.  Add the following code to your connection string and try it (Notice timeout in seconds):  connection timeout=500

Make sure you give it enough time to complete.
0
 
60MXGCommented:
How about the setting on SQL 2005?  I meant Connections setting when you have "Allow remote connections to this server" checked.  Try to set the "Remote query timeout" to 0 see if that will fix your problem.
0
 
PatricePaquetteAuthor Commented:
Hey,

First, thanks for answering.

I have tried both suggestions for the client side but the problem still persists. I will try your suggestion on the server side and will tell you if it works.

Thanks
0
 
Randy PetersonCommented:
You might want to try this in your code (syntax is C#)-  It looks like this is what I had to do to get the sproc longer time before the timeout.  This is in seconds, so it sets the timeout to 30 minutes in this example.

myCommand.CommandTimeout = 1800;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now