Wednesday, December 7, 2011

Difference between Execute Scalar and Execute Reader

What is the difference between Execute Scalar and Execute Reader? Execute Reader.. 1.Returns a datareader with data. 2.It is done by command object. 3.It is readonly. 4.It executes only select command. 5. This is known as a forward-only retrieval of records.It uses your sql statement to read through the table from the first to the last. Execute NonQuery.. 1.It will not return any data. 2.It is used with insert and update. 3.It returns only the number of rows affected. Execute Scaler.. 1.It returns only one value. 2.That value will the first column first row value. Execute Query.. 1.Its for command objects. 2.It returns the value given by database through select statemen...

Difference between for and foreach loop in c#

The for loop executes a statement or a block of statements repeatedly until a specified expression evaluates to false.  there is need to specify the loop bounds( minimum or maximum). int j = 0;for (int i = 1; i <= 5; i++) { j = j + i ; }The foreach statement repeats a group of embedded statements for each element in an array or an object collection.you do not need to specify the loop bounds minimum or maximum.int j = 0;int[] tempArr = new int[] { 0, 1, 2, 3, 5, 8, 13 }; foreach (int i in tempArr ) { j = j + i ...

Difference between an abstract class and interface Class

eatureInterfaceAbstract class Declaration and implementation of MethodsContain only declaration of functions and methods. It does not provide implementation of methods.We Can provide default implementation of methods. Implement Every Method or Override every methodThe derived class must implement all the methods of interface.Not necessary to implement all methods. Fields and ConstantsFields can not be defineFields can be define. Access ModfiersAn interface cannot have access modifiers for the functions, properties etc everything is assumed as publicAn abstract class can contain access modifiers for the functions, properti...

Page Life cycle in asp.net

Event Life cycle of ASP.NET 2.0 To track the flowing of events in web application, you need to add “trace = true” in page directive as shown below.       <% @Page Trace=”true”%>PreInit –1)    Entry point of page life cycle.2)    We can create or re-create dynamic controls.3)    We can change master page dynamically.4)    We can change theme properties dynamically in this control.Init -1)    All Control are initialized in this event2)    The init event of each controls occurs first then init event for page occurs. Init Complete –1)    Page is initialized.2)    Use this event to make changes...

multiple catch blocks in a single try statement

Yes. Multiple catch blocks may be put in a try block. See code example below, to see multiple catch blocks being used in C#. class ClassA{public static void Main(){int y = 0;try{val = 100/y;Console.WriteLine("Line not executed");}catch(DivideByZeroException ex){Console.WriteLine("DivideByZeroException" );}catch(Exception ex){Console.WritLine("Some Exception" );}finally{Console.WriteLine("This Finally Line gets executed always");}Console.WriteLine("Result is {0}",val)...

Asp.net Cross-Page PostBack example & Post Back

 Post Back means sending the data to server and return the data in same page. Cross-Page Post Back means sending the data from one page to another page.Example: CrossPagePostBack.aspx  <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>asp.net cross page postback example</title></head><body>    <form id="form1" runat="server">    <div>        <h2 style="color:Red">asp.net...

Ways To Optimize C# Code

Code optimization is an important aspect of writing an efficient C# application. The following tips will help you increase the speed and efficiency of your C# code and applications. 1. Knowing when to use StringBuilderYou must have heard before that a StringBuilder object is much faster at appending strings together than normal string types.The thing is StringBuilder is faster mostly with big strings. This means if you have a loop that will add to a single string for many iterations then a StringBuilder class is definitely much faster than a string type.However if you just want to append something to a string a single time then a StringBuilder class is overkill. A simple string type variable in this case improves on resources...

Dot Net Video Tutorial

Best Dot Net Video Tutorial Click the Below Link For More Info Click H...

Ado.net Interview Question

ExecuteReader : Use for accessing data. It provides a forward-only, read-only, connected recordset. ExecuteNonQuery : Use for data manipulation, such as Insert, Update, Delete. ExecuteScalar : Use for retriving 1 row 1 col. value., i.e. Single value. eg: for retriving aggregate function. It is faster than other ways of retriving a single value from D...

Visual Studio Keyboard Shortcuts

Visual Studio 2003 & 2005 Default Keyboard Shortcuts Text Manipulation Copy Ctrl + C Cut Ctrl + X Paste Ctrl + V Undo Ctrl + Z Redo Ctrl + Shift + Z Transpose characters Ctrl + T Transpose Lines Shift + Alt + T Transpose Words Ctrl + Shift + T Cut Line Ctrl + L Delete Line Ctrl + Shift + L Insert Line Above Ctrl + Enter Insert Line Below Ctrl + Shift + Enter Delete word to right Ctrl + Delete Delete word to left Ctrl + Backspace Collapse All Ctrl + M, O Toggle outlining Ctrl + M, M Toggle All Outlining Ctrl + M, L Comment Selection Ctrl + K, C Uncomment Selection Ctrl + K, U Format Selection Ctrl +K, F Format Document Ctrl + K, D Make lowercase Ctrl + U Make uppercase Ctrl + Shift + U Delete horizontal whitespace Ctrl + K, \ Toggle overtype/insert Insert Toggle wordwrap Ctrl +R,...

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | SharePoint Demo