Posts

Showing posts from July, 2008

Locking in Microsoft SQL Server

Introduction In this article, I want to tell you about SQL Server 7.0/2000 Transaction Isolation Levels, what kinds of Transaction Isolation Levels exist, and how you can set the appropriate Transaction Isolation Level, about Lock types and Locking optimizer hints, about deadlocks, and about how you can view locks by using the sp_lock stored procedure. Transaction Isolation Levels There are four isolation levels: READ UNCOMMITTED READ COMMITTED REPEATABLE READ SERIALIZABLE Microsoft SQL Server supports all of these Transaction Isolation Levels and can separate REPEATABLE READ and SERIALIZABLE . Let me to describe each isolation level. READ UNCOMMITTED When it's used, SQL Server not issue shared locks while reading data. So, you can read an uncommitted transaction that might get rolled back later. This isolation level is also called dirty read. This is the lowest isolation level. It ensures only that a physically corrupt data will not be read. READ COMMITTED This is the d

DIV Rounded Corners

CSS <style type="text/css"> .spiffy{display:block} .spiffy *{ display:block; height:1px; overflow:hidden; font-size:.01em; background:#B3A400} .spiffy1{ margin-left:3px; margin-right:3px; padding-left:1px; padding-right:1px; border-left:1px solid #ded791; border-right:1px solid #ded791; background:#c6ba3f} .spiffy2{ margin-left:1px; margin-right:1px; padding-right:1px; padding-left:1px; border-left:1px solid #f7f5e5; border-right:1px solid #f7f5e5; background:#c1b530} .spiffy3{ margin-left:1px; margin-right:1px; border-left:1px solid #c1b530; border-right:1px solid #c1b530;} .spiffy4{ border-left:1px solid #ded791; border-right:1px solid #ded791} .spiffy5{ border-left:1px solid #c6ba3f; border-right:1px solid #c6ba3f} .spiffyfg{ background:#B3A400} </style> HTML <div> <b class="spiffy"> <b class="spiffy1"><b></b></b> <b class="spi

Convert DOC to PDF Files (Convert Word To PDF Files) using Command in ASP.Net

I used http://www.softinterface.com/Convert-Doc/Features/Convert-DOC-to-PDF.htm and then Executed the command from Asp.Net to conver the MS Word files to PDF. Code         // write the command         string exec = TextBox1.Text;         // Create the ProcessInfo object         System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");         psi.UseShellExecute = false;         psi.RedirectStandardOutput = true;         psi.RedirectStandardInput = true;         psi.RedirectStandardError = true;                 // The path where Application is installed         psi.WorkingDirectory = "C:\\Program Files\\Softinterface, Inc\\Convert Doc";         // Start the process         System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);         // Open the batch file for reading         //System.IO.StreamReader strm = System.IO.File.OpenText(strFilePath);         System.IO.StreamReader strm = proc.StandardError;      

Numeric TextBox (ASP.Net / HTML Input)

< script language ="javascript"> function KeyCheck(e) { var KeyID = (window. event ) ? event .keyCode : e.which; if ((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126)) { return false ; } return true ; } </ script > HTML Text Box < input type ="text" ID ="txt_TextBox" onkeypress ="return KeyCheck(event);" runat ="server" style ="width: 28px" /> ASP.Net TextBox < asp : TextBox ID ="txt_ASPTextBox" runat ="server" ></ asp : TextBox > Code Behind for Asp.Net TextBox txt_ASPTextBox.Attributes.Add( "onkeypress","return KeyCheck(event);" );

Insert / Delete / Update Row in DataGrid at Runtime from Other GridView

Grid 1 < asp : GridView ID ="gv_Source" runat ="server" AutoGenerateColumns ="False" OnRowCommand ="gv_Source_RowCommand" Width ="100%"> < Columns > < asp : BoundField DataField ="TemplateName" HeaderText ="Template Name" /> < asp : TemplateField > < ItemTemplate > < input type ="text" ID ="txt_TextBox" runat ="server" style ="width: 28px" /> < asp : Label ID ="lbl_Required" runat ="server" Font-Bold ="True" ForeColor ="Red" Text ="*" Visible ="False"></ asp : Label > </ ItemTemplate > </ asp : TemplateField > < asp : TemplateField > < ItemTemplate > < asp : LinkButton ID ="lnkbt_SelectTemplates" runat ="server" Text ="Select" CommandArgument =' <%# ((GridViewRow)Contain

GridView (Multiple check Boxes Selection / Get Checked Check Boxes)

Grid View < asp : GridView ID ="GridView1" runat ="server" AutoGenerateColumns ="False" > < Columns > < asp : BoundField DataField ="Column1" HeaderText ="Column" /> < asp : TemplateField HeaderText ="TextBox"> < ItemTemplate > < asp : TextBox ID ="txt_TextBox" runat ="server" ></ asp : TextBox > </ ItemTemplate > </ asp : TemplateField > < asp : TemplateField HeaderText ="Select"> < HeaderTemplate > Select All < input id ="chkAll" onclick ="javascript:SelectAllCheckboxes(this);" runat ="server" type ="checkbox" /> </ HeaderTemplate > < ItemTemplate > < asp : CheckBox ID ="chk_Selected" runat ="server" /> </ ItemTemplate > </ asp : TemplateField > </ Columns > </ asp : GridView > Java

Exception Handling (Exception logging)

using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace ExceptionLogger { public class ExceptionLogger { public static void WritetoCustomEventLog(Exception paramEntry, EventLogEntryType paramType) { string str_Source = "ERROR LOG"; //Source Name string str_LogType = "My Test LOG"; //Your log Name if it does not exists then first it will create and then add entry string str_Machine = "."; //machine name if (!System.Diagnostics.EventLog.SourceExists(str_Source, str_Machine)) { System.Diagnostics.EventLog.CreateEventSource(str_Source, str_LogType, str_Machine); } string ExceptionDetail = ""; ExceptionDetail = "Message : " + paramEntry.Message + "\n"; ExceptionDetail += "Stack Trace : " + paramEntry.StackTrace + "\n";

Access Master Pages Properties

There are different techniques to access MasterPages properties Master Page Code file: public partial class MyMasterPageClass: System.Web.UI.MasterPage { public string ErrorMessage { set { lblErrorPane.Text = value; panelErrorMessage.Visible = true; } } } Content Page 1) (( MyMasterPageClass )Master).ErrorMessage = " Test Error Message"; After adding this <%@ MasterType VirtualPath="~/MasterPage.master" %> under Page Directive you can access the property of master page directly. 2) this.Master.ErrorMessage = "Test Message";

Unique String Generator

using System; using System.Security.Cryptography; public class UniqueStringGenerator { private static int DEFAULT_MIN_STRING_LENGTH = 20; private static int DEFAULT_MAX_STRING_LENGTH = 20; private static string STRING_CHARS_LCASE = "abcdefgijkmnopqrstwxyz"; private static string STRING_CHARS_UCASE = "ABCDEFGHJKLMNPQRSTWXYZ"; private static string STRING_CHARS_NUMERIC = "23456789"; private static string STRING_CHARS_SPECIAL = "*$-+?_&=!%{}/"; public static string Generate() { return Generate(DEFAULT_MIN_STRING_LENGTH, DEFAULT_MAX_STRING_LENGTH); } public static string Generate(int length) { return Generate(length, length); } public static string GenerateWithSpecialCharacters() { return GenerateWithSpecialCharacters(DEFAULT_MIN_STRING_LENGTH, DEFAULT_MAX_STRING_LENGTH); } public static string GenerateWithSpecialCharacters(int lengt