Sunday, October 29, 2017
Saturday, February 14, 2009
Difference b/w COUNT_BIG and COUNT in SQL server
Difference b/w COUNT_BIG and COUNT in SQL server
1.Count_big always returns the Bingint values...but count returns the
int values
2.Both count the No of Rows in a table
To Create Custom exception in C#.Net
To Create Custom exception in C#.Net
#region Custom Exception Classesclass ExTask : Exception
{
public ExTask()
{ }
public ExTask(string message)
: base(message)
{ }
}
#endregion
==================================================================
To catch the custom Exception :
catch (ExTask ex)
{
// Do to Log Handler
}
==================================================================
For the above example "ExTask" is the custom exception name.
1.your Exception wants to inherit the exception base class.
2.You have to create a default constructor,,,, two method we
wants to call the base class Exception contructor.
To Execute the Remote Machine Process Example To reset the iis of remote machine
To Execute the Remote Machine Process Example To reset the iis of remote machine
ProcessStartInfo psi = new ProcessStartInfo("iisreset.exe", "RematoreMachineName -stop");
psi.UserName = "RemoteMachineUserName";
psi.Domain = "DomainNameOfRemoteMachine";
psi.UseShellExecute = false;
string password = "RemoteMachinePassword";
System.Security.SecureString o = new System.Security.SecureString();
foreach (char c in password)
{
o.AppendChar(c);
}
psi.Password = o;
Process.Start(psi);
Information about W3wp.exe File
Information about W3wp.exe File
Description: File w3wp.exe is located in a subfolder of C:\Windows\System32 or sometimes in a subfolder of "C:\Program Files". Known file sizes on Windows XP are 7168 bytes (66% of all occurrence), 6656 bytes.
w3wp.exe is a Windows system file. The program has no visible window. w3wp.exe is a trustworthy file from Microsoft. Program listens for or sends data on open ports to LAN or Internet. Therefore the technical security rating is 4% dangerous, however also read the users reviews.
If w3wp.exe is located in the folder C:\Windows\System32 then the security rating is 84% dangerous. File size is 48128 bytes (40% of all occurrence), 57344 bytes, 798208 bytes. There is no information about the maker of the file. The program has no visible window. w3wp.exe is located in the Windows folder, but it is not a Windows core file. w3wp.exe is not a Windows system file. The process listens for or sends data on open ports to LAN or Internet. w3wp.exe is able to hide itself, monitor applications.
How to add double quotes to a string that is inside a variable?
How to add double quotes to a string that is inside a variable?
We can use double quotes on the string.Example :
Declaration:
__________
string a="double quotes Example";
string b= "\""+a+"\"";
The out put is like this:
_________________
a= double quotes Example;
b= " double quotes Example";
Tuesday, February 10, 2009
Region based default button in ASP.NET
Region based default button in ASP.NET
Another one Simple Method is use the Panel inside it put the Default Button Focus To It<!--
--!>
You can also kept the focus coding at the Form tag itself
If we want to provide the enter key focus based on the particular region we can use panel (or) form tag with "defaultbutton" properties.
Inside the panel you may kept anything else...table,div tag anything whatever u want to
Consider your cursor points to that's location on that if any enter key get fired then the default event focus to the control. For the above example the Button3 click event get fires on the enter key click event.
Getting the group of files from directory with the name specific
Getting the group of files from directory with the name specific
DirectoryInfo di = new DirectoryInfo("c:\\accounts");
FileInfo[] fArr = di.GetFiles("??A??.txt");
for (int iCounter = 0 ; iCounter <>
iCounter++)
{
string str = fArr[iCounter].Name;
}
For the above Example i am loading the group of files from the directory of "C:\\\accounts" with the file third letter of "A"
di.GetFiles("A??.txt");
For the above Example i am loading the group of files from the directory of "C:\\\accounts" with the file Name starts with the letter "A"
Random string generation in C#.Net
Random string generation in C#.Net
private string RandomString(int size, bool lowerCase){
StringBuilder builder = new StringBuilder();
Random random = new Random();
char ch ;
for(int i=0; i
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
builder.Append(ch);
}
if(lowerCase)
return builder.ToString().ToLower();
return builder.ToString();
}
Dynamically load user control in ASP.NET Webform
Dynamically load user control in ASP.NET Webform
User Controls are semi-autonomous pages of HTML and underlying ASP.NET code that can be inserted into ASP.NET pages. As such they are useful for adding blocks of functionality to pages. Typical uses are to use User Controls for page headers and footers. They can also add functionality such as a "property of the week" for a real estate company website.
Unlike ASP.NET pages that have the .aspx file extension, User Controls typically have the .ascx file extension. Once created, in Visual Studio.NET they can be included in a specific page by simply dragging the user control onto the design view of that page. Alternatively, they can be added to a page at design time by including the following in the page's HTML. For example, the following line includes a header user control from the HeaderUserControl.ascx file:
<%@ Register TagPrefix="uc1" TagName="HeaderUserControl" Src="HeaderUserControl.ascx" %>
The header is then positioned on the page using the following tag:
Although this procedure is satisfactory for content like headers and footers that will always be required on specific pages, it would be useful if there was a way of dynamically loading specific user controls at run time. For example, an online store may only want a "clearance offers" section to appear if there is actually stock inventory in the database that has been marked as being for clearance.
Fortunately, it is possible to load user controls onto a page by making use of the LoadControl method. This function has a straightforward syntax - it takes a single argument - the virtual path to the user control page. For example, to load the featured product user control the following C# code would be used within the Page_Load method:
Control FeaturedProductUserControl = LoadControl("FeaturedProduct.ascx");
Once the user control has been loaded, it can be added to the page by adding it to the Controls collection:
Controls.Add(FeaturedProductUserControl);
The drawback with this technique is that it offers no control over where on the page the user control will actually appear. A useful tip is, therefore, to add a place holder control to the page in the position that you want it to display the dynamically loaded user controls. A place holder does just that - it acts as a container for other controls. You can then specify that the user control appear within the place holder by adding the user control to the place holder's controls collection:
PlaceHolderLeftMenu.Controls.Add(FeaturedProductUserControl);
Alternatively it is possible to position the user control in other ways, such as adding it to a Panel control:
PanelRightMenu.Controls.Add(FeaturedProductUserControl);
Creating a Cookie in ASP.NET
Creating a Cookie in ASP.NET
#region Creating CookiesHttpCookie JayaCookie = Request.Cookies["CookieExample"];
if (HttpContext.Current.Request.Cookies["CookieExample"].Value == null)
{
HttpContext.Current.Response.Cookies["CookieExample"].Value = Session.SessionID;
HttpContext.Current.Response.Cookies["CookieExample"].Expires = DateTime.Now.AddYears(30);
}
#endregion
For the above Example the cookie name is "CookieExample".I assigned the SessionID value to the cookie
Use of Sealed Keyword (or) Sealed Method
Use of Sealed Keyword (or) Sealed Method
The sealed method cannot be override at the derived class. it is mainly associated with the
override method.
For the below example at the DerivedSealed1 class the override function Base() associated with the "sealed" keyword.So it can't able to override the next level of inheritance.
For the below example the error thrown at the "DerivedSealed2 " override Base() Function.
If DerivedSealed1 the Base() override is not associated with the "sealed" keyword this wont thrown the error.
I hope that u can understand the use of "sealed Keyword"
public class BaseSealed
{
public virtual void Base()
{
Console.WriteLine("I am in Base Class");
}
}
public class DerivedSealed1 : BaseSealed
{
public sealed override void Base()
{
Console.WriteLine("I am in Derived Class 1");
}
}
public class DerivedSealed2 : DerivedSealed1
{
public override void Base()
{
Console.WriteLine("I am in Derived Class 2");
}
}
Difference between copy and clone in .NET
Difference between copy and clone in .NET
Copy:_____
It copies both tha data and schema and the data.
Clone:
______
It copies the schema alone.And later we can add the rows belongs to it.
Which DLL handle *.aspx request?
Which DLL handle *.aspx request?
aspnet_isapi.dll Handles the *.aspx request.
Javascript File loading time in ASP.NET
Javascript File loading time in ASP.NET
U well know javascripts are running in the client machine. For example consider a ASP.NET web
form we used 2 javascript file means the client browser open and close a new connection for
loading each file from server to client.This will degrade performance of the page loading time .
So How big you are using the file is not a matter.The way of loading the file soon is important.
Example(1) 50 kb of a single file takes 6ms to load
A page load 3 javascript file.Those file total size is 20kb. This page takes 10ms to load
Page from server to client.
So Keep on considering how many files you are loading on a single page.This is one of the main performance issue.
Shell command in VBScript
Shell command in VBScript
'VBScript File
dim program
program="C:\Windows\System32\notepad.exe"
set oShell =CreateObject("wscript.shell")
oShell.Run(program)
For the above example i am running the system file through shell command
Taskkill.exe (Kill the task that running on local and remote machine)
Taskkill.exe (Kill the task that running on local and remote machine)
Examples:
TASKKILL /S system /F /IM notepad.exe /T
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM notepad.exe /IM mspaint.exe
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
U can run this command through process class in .NET
what is Wrapper?
what is Wrapper?
We overwrite the original function into user friendly function.That function is called as wrapper.
For Example below consider the original function have 5 argument and it process those five argument
public void originalFunction(string arg1,string arg2,string arg3,string arg4,string arg5)
{
//Some processing happening by the use of those parameter
}
For the above example consider if we only often need to send 3 parameters. we no need to send another 2 parameters.
We can create a wrapper function and internally get call that original function:
Example:
public void WrapperFunction(string arg1,string arg2,string arg3,"","")
{
originalFunction(string arg1,string arg2,string arg3,"","");
}
For above WrapperFunction is a "Wrapper" for originalFunction. Above we just hard coded the unnecessary last 2 arguments.
Subscribe to:
Posts (Atom)
-
What are Structural Design Patterns? A structural design pattern establishes a relationship between entities. Thus making it easier for...
-
Name value collection in C# The name value collection is same like the HashTable. We can set the Object value and the Key to that par...