Skip to main content

Posts

Clear all the rows in a table resetting the identity specification back to zero and without affecting the foreign keys?

You can take the following steps: -- disable all foreign key constraints EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" -- delete data in all tables EXEC sp_MSForEachTable "DELETE FROM ?" -- enable all constraints exec sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all" More on disabling constraints and triggers here if some of the tables have identity columns we may want to reseed them EXEC sp_MSforeachtable "DBCC CHECKIDENT ( '?', RESEED, 0)" Note that the behaviour of RESEED differs between brand new table, and one which had had some date inserted previously from BOL

Resizing an Image without losing any quality

public static byte[] CreateThumbnail(byte[] imageBytes, int lnWidth, int lnHeight)     {         byte[] b;         System.Drawing.Bitmap bmpOut = null;         try         {             Bitmap loBMP = new Bitmap(System.Drawing.Image.FromStream(new MemoryStream(imageBytes)));             ImageFormat loFormat = loBMP.RawFormat;             decimal lnRatio;             int lnNewWidth = 0;             int lnNewHeight = 0;             if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)             {                 //NEW.............................................................................................************ ...

Using jQuery to center a DIV on the screen

Create Function $.fn.center = function () {             this.css({                 'position': 'fixed',                 'left': '50%',                 'top': '50%'             });             this.css({                 'margin-left': -this.width() / 2 + 'px',                 'margin-top': -this.height() / 2 + 'px'             });             return this;         } ----------------------------------- Use this function $("#control_Id").center();

Conversion Algorithms

using System; using System.Collections.Generic; using System.Text; namespace ConversionAlgorithms {     class clsConversion     {         // Convert Degree to Radian         public static double DegreeToRadian(double degree)         {             return (Math.PI / 180) * degree;                     }         // Convert Radian To Degree         public static double RadianToDegree(double radian)         {                         return (180 / Math.PI) * radian;         }         // Round Float to Integer         public static int RoundFloatToInt(float f)         {             retur...

explain synchronous and asynchronous in C#

Usually the methods are synchronous. That means that you call them, they gets executed. And when they finish you get the control back. The asynchronous methods are different. You call them. They start executing, but return the control over the execution back to the thread which called them while they continue to execute in different thread. ------------------------------------------------------------- Synchronous is one after another, so you send one email when that process is done it sends the next one. Asynchronous starts sending an email and it doesn't care if the first one is done and will start the second, and this goes on until all emails are sent. Normally, an asynchronous process would open a new thread and run in the background.

Can I set an unlimited length for maxJsonLength in web.config?

The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k). You can set the MaxJsonLength property on your web.config: <configuration> <system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength = "50000000" /> </webServices> </scripting> </system.web.extensions> </configuration>