Unable to modify table, timeout expired errors with Microsoft SQL Server

While modifying a table in Microsoft SQL Server with about 10 million records in it, I got the error message “unable to modify table – timeout expired…” and the table was not able to be modified. The solution was to change the timeout settings which is covered in this post.

 

When I first attempted to save my changes to the table, I got an initial warning after a few seconds as shown in the screenshot below.
warnings were encountered during the pre-save validation process

The full text from the message in the above screenshot is “Warnings were encountered during the pre-save validation process, and might result in a failure during save. Do you want to continue attempting to save?” And then “Saving Definition Changes to tables with large amounts of data could take a considerable amount of time. While changes are being saved, table data will not be accessible.” Naturally I clicked the “Yes” button after getting this warning because I really did want my changes saved. Also I’d paused the process which updates this table so it wouldn’t result in any errors while I was saving the new table structure.

After 30 seconds, I got the error message in the following screenshot.

errors were encountered during the save process

The full text from the above screenshot is “Errors were encountered during the save process. Some database objects were not saved” and “Unable to modify table. Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.” The changes to the table that I had attempted to make were not saved and the table structure was the same as it had been previously.

The issue is caused by a timeout setting for “table designer updates” which is set to 30 seconds as the default value. If your changes cannot be saved in this time then they will not be. To change the setting, go to “Tools” and then “Options” from the main menu of your SQL Server Management tool. Then click on the “Designers” section of the options. This is shown in the screenshot below.

changing the transaction timeout

The value that needs to be changed is highlighted with a red box in the screenshot above and is labelled “Override connection string time-out value for table designer updates” and “Transaction time-out after”. Change the default 30 seconds value to some higher value, click the “OK” button and run your table structure change again.

Note that the transaction time-out setting must be a numerical value greater than 0. Setting it to 0 to prevent any timeouts will not work and you will be presented with an error message as shown in the screenshot below.

valid range is 1 to 65535

You can set it to any value between 1 and 65535. Given that this is in seconds, 65535 is over 18 hours so setting it to the maximum value would normally work. For my table with 10 million records, I set it to 600 seconds (10 minutes) to see if that would work. The actual table save took more than 10 minutes but it didn’t time out, which surprised me, and the new table structure took affect after that.

Note that while the table structure is being saved, the SQL Server Management tool is completely inaccessible and the window is usually blanked out like it has crashed. Just wait until it’s all done and you should be alright.

via: http://www.electrictoolbox.com/unable-modify-table-timeout-expired-sql-server/

VIDEO: Simplificar vistas ASP.NET MVC utilizando helpers personalizados

En las vistas ASP.NET MVC es bastante habitual encontrar código duplicado o demasiado complejo que dificulta la legibilidad y mantenibilidad de las mismas. Y como desarrolladores, sabemos que esto es una bomba de relojería: antes o después tendremos que modificarlas y es en ese momento cuando valoraremos especialmente encontrarnos con un código conciso, limpio, y bien estructurado.

Para ayudarnos en ello, el framework MVC ofrece un mecanismo denominado helpers (pertenecientes a la sintaxis Razor), cuya misión principal es encapsular lógica de generación de código de vista, o, en otras palabras, introducir HTML por nosotros en el interior de la página. Ejemplos conocidos son los helpers para crear hiperenlaces o editores de campos de formulario como Html.ActionLink() o Html.EditorFor(), proporcionados de serie por ASP.NET MVC. Estos son helpers de alcance global y pueden ser usados en todas las vistas de la aplicación.

Pero, adicionalmente, el framework ofrece la posibilidad de crear helpers específicos para una vista concreta, que podemos utilizar para conseguir un código mucho más simple y mantenible en el interior de la misma, como veremos en el siguiente vídeo.

via: http://www.campusmvp.es/recursos/post/VIDEO-Simplificar-vistas-ASPNET-MVC-utilizando-helpers-personalizados.aspx

VIDEO: Activar la compilación de vistas en ASP.NET MVC

Como sabemos, en proyectos ASP.NET MVC las vistas Razor/ASPX son compiladas en tiempo de ejecución, cuando se produce el primer acceso a las mismas.

Aunque esto ofrece algunas ventajas, como la reducción del tiempo de compilación o la posibilidad de modificarlas “en caliente”, es decir, durante la ejecución de la aplicación, introduce también un inconveniente importante: los errores que hayamos cometido en su implementación no serán detectados hasta que la página sea visualizada, hecho que, en el peor de los casos, se producirá ya en producción.

Para evitar este tipo de situaciones, ASP.NET MVC incluye la posibilidad de llevar a tiempo de compilación la comprobación de errores en vistas. El problema es que la forma de conseguirlo es algo extraña, pues no está soportado directamente por el entorno de Visual Studio y hay que retocar a mano el archivo del proyecto.

En cualquier caso no es nada complicado, en el siguiente vídeo veremos cómo hacerlo:

De esta forma tendremos la seguridad de que nuestras vistas compilan perfectamente, sólo a cambio de un poco más de tiempo en el momento de construir la solución.

Pero ojo, recordad que se trata simplemente de una comprobación de errores para facilitar la depuración, y en ningún caso sustituye a la compilación que el proceso de ASP.NET realizará una vez despleguemos el proyecto.

via: http://www.campusmvp.es/recursos/post/Activar-la-compilacion-de-vistas-en-ASPNET-MVC.aspx