Server Error in Application

An unhandled exception occurred during the execution of the current web request
posts - 60 , comments - 75 , trackbacks - 50

My Links

News

Archives

Post Categories

ASP.NET

Wednesday, October 15, 2008

More relaxing jobs are more dangerous: Economic Slowdown, JOB CUTs and Software Developer.

I just posted  article about "Economic Slowdown, JOB CUTs and Software Developer." I wish everybody should not to be in situation to read this.....
More relaxing jobs are more dangerous: Economic Slowdown, JOB CUTs and Software Developer

Related Post Talent vs Attitude – Harsha Bhogle

Posted On Wednesday, October 15, 2008 2:36 PM | Comments (0) | Filed Under [ ASP.NET C# Web Services Design Pattern BizTalk unhandled exception ]

Friday, September 19, 2008

SQL Server 2005 (Database) Interview Questions

SQL Server 2005 Interview Questions

1. What is DESCRIBE command in SQL Server 2005? What is its purpose? How to use it?

DESCRIBE is used to see table structure. In SQL server 2005 we can use sp_columns, sp_tables or sp_help.

sp_columns

will show list of columns and its details in table.
sp_tables will show list of tables in the databas

 2. What is RDBMS?

Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships created and maintained across tables between data. Interdependencies between these tables are defined by the data values.

RDMS is based upon relational modal of E.F.Codd

 3. Can UNIQUE KEY in SQL Server 2005 have two or more NULL?

SQL server 2005 can not have more then one NULL, because in SQL server 2005 every null is having same value. UNIQUE KEY in ORACLE can have more then one NULL values as every NULL in ORACLE is having unique value.

4. What is a "trigger" in SQL Server 2005?

In  any database including SQL Server 2005 a trigger is procedure that initiates on INSERT, DELETE or UPDATE actions. Before SQL Server 2000 Triggers are also used to maintain the referential integrity. We can not execute triggers explicitly; the DBMS automatically fires the trigger when data modification events (INSERT, DELETE or UPDATE) happened in the associated table.
Triggers are same as stored procedures in term of procedural logic that is stored at the database level. Stored procedures are executed explicitly and triggers are event-drive.
Triggers can also execute stored procedures.

Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger. See Create Trigger for more

5. What is View in Database (SQL Server 2005, ORACLE)?

 As per the theory of database (which includes SQL Server 2005, Oracle etc.) a view can be thought of stored SQL query which result can be accessible as a table. It can be used for retrieving data, as well as updating or deleting rows.
But database view does not have physical schema

The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.

See more on Database Views

 6. How do you optimize stored procedures in SQL Server 2005?

1.    Use as much as possible WHERE clause filters. Where Clause is the most important part for optimization
2.    Select only those fields which really require.
3.    Joins are expensive in terms of time. Make sure that use all the keys that relate the two tables together and don't join to unused tables, always try to join on indexed fields. The join type is important as well (INNER, OUTER).

 7. How is the error handling in stored procedures of SQL Server 2005? 

In previous versions of SQL Server you would handle exceptions by checking the @@error global variable immediately after an INSERT, UPDATE or DELETE, and then perform some corrective action if @@error did not equal zero.

SQL Server 2005 provides structured exception handing through TRY CATCH block as other programming language like JAVA, C# etc.

BEGIN TRY
 RAISERROR ('Yaa, I ma the problem', 16,1)
END TRY
 
BEGIN CATCH
 SELECT ERROR_NUMBER() as ERROR_NUMBER,
   ERROR_SEVERITY() as ERROR_SEVERITY,
   ERROR_STATE() as ERROR_STATE,
   ERROR_MESSAGE() as ERROR_MESSAGE
END CATCH
 

ERROR_NUMBER() returns the number of the error.
ERROR_SEVERITY() returns the severity.
ERROR_STATE() returns the error state number.
ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.
ERROR_LINE() returns the line number inside the routine that caused the error.
ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names or times.

 

Related Post:

Association, Aggregation, Composition object relationship

Talent vs Attitude – Harsha Bhogle

What we can learn from Babies

 

Posted On Friday, September 19, 2008 2:49 AM | Comments (0) | Filed Under [ ASP.NET C# Web Services Design Pattern BizTalk unhandled exception ]

Monday, June 9, 2008

A Leader Should Know How to Manage Failure'

Former President of India APJ Abdul Kalam at Wharton India Economic forum , Philadelphia, United States March 22,2008)

Question: Could you give an example, from your own experience, of how leaders should manage failure?

Kalam:   Let me tell you about my experience. In 1973 I became the project director of India's satellite launch vehicle program, commonly called the SLV-3. Our goal was to put India's "Rohini" satellite into orbit by 1980. I was given funds and human resources -- but was told clearly that by 1980 we had to launch the satellite into space. Thousands of people worked together in scientific and technical teams towards that goal.

By 1979 -- I think the month was August -- we thought we were ready. As the project director, I went to the control center for the launch. At four minutes before the satellite launch, the computer began to go through the checklist of items that needed to be checked. One minute later, the computer program put the launch on hold; the display showed that some control components were not in order. My experts -- I had four or five of them with me -- told me not to worry; they had done their calculations and there was enough reserve fuel. So I bypassed the computer, switched to manual mode, and launched the rocket. In the first stage, everything worked fine. In the second stage, a problem developed. Instead of the satellite going into orbit, the whole rocket system plunged into the Bay of Bengal. It was a big failure.

That day, the chairman of the Indian Space Research Organization, Prof. Satish Dhawan, had called a press conference. The launch was at 7:00 am, and the press conference -- where journalists from around the world were present -- was at 7:45 am at ISRO's satellite launch range in Sriharikota [in Andhra Pradesh in southern India]. Prof. Dhawan, the leader of the organization, conducted the press conference himself. He took responsibility for the failure -- he said that the team had worked very hard, but that it needed more technological support. He assured the media that in another year, the team would definitely succeed. Now, I was the project director, and it was my failure, but instead, he took responsibility for the failure as chairman of the organization.

The next year, in July 1980, we tried again to launch the satellite -- and this time we succeeded. The whole nation was jubilant. Again, there was a press conference. Prof. Dhawan called me aside and told me, "You conduct the press conference today."

I learned a very important lesson that day. When failure occurred, the leader of the organization owned that failure. When success came, he gave it to his team. The best management lesson I have learned did not come to me from reading a book; it came from that experience
….
 

Related Post:
Talent vs Attitude – Harsha Bhogle

Posted On Monday, June 9, 2008 8:26 PM | Comments (1) |

Monday, June 2, 2008

technorati

Technorati Profile

Posted On Monday, June 2, 2008 9:01 PM | Comments (0) |

Friday, May 23, 2008

IE 7 Vs Firefox Vs Safari

I did quick test to check which browser eats more memory. My test is not so robust. I only open 4 similar pages into all the browser and check the memory uses into Window task manager. What I found Safari eats more memory then IE 7 and least memory consume by Firefox. I am not saying this test is a sufficient test for browsers. Here is snapshot.


Posted On Friday, May 23, 2008 12:21 AM | Comments (0) |

Thursday, January 10, 2008

ASP.NET 2.0 Interview Questions

Related Post:
Talent vs Attitude – Harsha Bhogle

Association, Aggregation, Composition object relationship

What we can learn from Babies

ASP.NET 2.0 Interview Questions

1. What is the name of the property of ASP.NET page that you can query to determine that a ASP.NET page is being requested not data being submitted to web server?
A. FirstGet
B. Initialized
C. IncludesData
D. IsPostBack

IsPostBack

2. While creating a Web site with the help of Visual Studio 2005 on a remote computer that does not have Front Page Server Extensions installed, which Web site type will you create in Visual Studio 2005?
A. Remote HTTP
B. File
C. FTP
D. Local HTTP

Hypertext Transfer Protocol (HTTP)

3. If you want to create a new Web site with the help of Visual Studio 2005 on a Web server that is hosted by your ISP (Internet Services provider) and the Web server has Front Page Server Extensions installed, what type of Web site type would you create in Visual Studio 2005?
A. Local HTTP
B. File
C. FTP
D. Remote HTTP

Hypertext Transfer Protocol (HTTP)

4. For separating server-side code from client-side code on a ASP.NET page, what programming model should you use?
A. Separation model
B. Code-Behind model
C. In-Line model
D. ClientServer model

5. Amit created a new Web site using Visual Studio 2005 in programming language C#. Later, Amit received an existing Web page from his boss, which consisted of the Contact.aspx file with the Contact.aspx.vb code-behind page. What must Amit do to use these files?
A. Amit can simply add the files Contact.aspx, Contact.aspx.vb into the existing Web site, because ASP.NET 2.0 supports Web sites that have Web pages that were programmed with different languages.
B. The Contact.aspx file will work, but Amit must rewrite the code-behind page using C#.
C. Both files Contact.aspx and Contact.aspx.vb must be rewritten in C#.
D. Amit must create a new Web site that contains these files Contact.aspx and Contact.aspx.vb. Set a Web reference to the new site.

6. If you want to make a configuration setting change in your server that will affect to all Web and Windows applications on the current machine. Where you will make the changes?
A. Global.asax
B. Web.config
C. Machine.config
D. Global.asax

7. If you want to make a configuration setting change that will affect only the current Web application. Which file will you change?
A. Web.config that is in the same folder as the Machine.config file
B. Web.config in the root of the Web application
C. Machine.config
D. Global.asax

8. For making a configuration setting change that will affect only the current Web application. Is there any tool that has a user-friendly Graphical User Interface (GUI)?
A. The Microsoft Management Utility
B. Microsoft Word
C. Visual Studio, using the Tools > Options path
D. Web Site Administration Tool

ASP.NET 2.0 Interview Questions

9. How will you identify which event in the ASP.NET Web page life cycle takes the longest time to execute?
A. Turn on ASP.NET trace and run the Web application.
B. Add a few code to each of the page life-cycle events that will print the current time.
C. In the Web.config file, add the monitorTimings attribute and set it to True.
D. In the Web site properties, turn on the performance monitor and run the Web application. After that, open performance monitor to see the timings.

11. You are interested in examining the data that is posted to the Web server. What trace result section can you use to see this information?
A. Control Tree
B. Headers Collection
C. Form Collection
D. Server Variables

12. While creating web site you need to add an HTML Web server control to the Web page, you need to drag an HTML element from the ToolBox of Visual Studio 2005 to the Web page and then which of the following tasks you will perform?
A. Right-click the HTML element and click Run=Server.
B. Double-click the HTML element to convert it to an HTML server control.
C. Right-click the HTML element and click Run As Server Control.
D. Click the HTML element and set ServerControl to true in the Properties window.

13. While testing your ASP.NET web application you noticed that while clicking on CheckBox of one of the web page it does not cause a PostBack; you required that the CheckBox should make PostBack so Web page can be update on the server-side code. How can you make the CheckBox to cause a PostBack?
A. Set the AutoPostBack property to true.
B. Add JavaScript code to call the ForcePostBack method.
C. Set the PostBackAll property of the Web page to true.
D. Add server-side code to listen for the click event from the client.

14. While writing code in Visual Studio 2005 you creates a new instance of a ASP.NET TextBox server control, what do you need to do to get the TextBox to display on the Web page?
A. Call the ShowControl method on the TextBox.
B. Set the VisibleControl to true on the TextBox.
C. Add the TextBox instance to the form1.Controls collection.
D. Execute the AddControl method on the Web page.

15. While creating your ASP.NET web based application you want to create multiple RadioButton server controls which should be mutually exclusive, what property of RadioButton server controls you must set?
A. Exclusive
B. MutuallyExclusive
C. Grouped
D. GroupName

16. While creating an ASP.NET web application with the help of Visual Studio 2005 you are creates a Web page that has several related buttons, such as fast-forward, reverse, play, stop, and pause. There should be one event handler that handles the processes of PostBack from these Button server controls. Other than the normal Submit button, what type of button can you create?
A. OneToMany
B. Command
C. Reset
D. ManyToOne

ASP.NET 2.0 Interview Questions

17. In the Design view in Visual Studio 2005 of an ASP.NET web page, what is the easiest way to create an event handler for the default event of a ASP.NET server control?
A. Open the code-behind page and write the code.
B. Right-click the control and select Create Handler.
C. Drag an event handler from the ToolBox to the desired control.
D. Double-click the control.

18. Which of the following represents the best use of the Table, TableRow, and Table-Cell controls?
A. To create and populate a Table in Design view
B. To create a customized control that needs to display data in a tabular fashion
C. To create and populate a Table with images
D. To display a tabular result set

19. For your ASP.NET web application your graphics designer created elaborate images that show the product lines of your company. Some of graphics of the product line are rectangular, circular, and others are having complex shapes. You need to use these images as a menu on your Web site. What is the best way of incorporating these images into your Web site?
A. Use ImageButton and use the x- and y-coordinates that are returned when the user clicks to figure out what product line the user clicked.
B. Use the Table, TableRow, and TableCell controls, break the image into pieces that are displayed in the cells, and use the TableCell control’s Click event to identify the product line that was clicked.
C. Use the MultiView control and break up the image into pieces that can be displayed in each View control for each product line. Use the Click event of the View to identify the product line that was clicked.
D. Use an ImageMap control and define hot spot areas for each of the product lines. Use the PostBackValue to identify the product line that was clicked.

20. You are writing ASP.NET 2.0 Web site that collects lots of data from users, and the data collection forms spreads over multiple ASP.NET Web pages. When the user reaches the last page, you need to gather all of data, validate the data, and save the data to the SQL Server database. You have noticed that it can be rather difficult to gather the data that is spread over multiple pages and you want to simplify this application. What is the easiest control to implement that can be used to collect the data on a single Web page?
A. The View control
B. The TextBox control
C. The Wizard control
D. The DataCollection control

21. In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?
A. Use the ImageMap control and randomly select a HotSpot to show or hide.
B. Use the Image control to hold the image and a Calendar control to randomly select a date for each image to be displayed.
C. Use the AdServer control and create an XML file with configuration of the control.
D. Use an ImageButton control to predict randomness of the image to be loaded based on the clicks of the control.

22. In your ASP.NET web application you want to display a list of clients on a Web page. The client list displays 10 clients at a time, and you require the ability to edit the clients. Which Web control is the best choice for this scenario?
A. The DetailsView control
B. The Table control
C. The GridView control
D. The FormView control

23. While developing ASP.NET 2.0 web application you want to display a list of parts in a master/detail scenario where the user can select a part number using a list that takes a minimum amount of space on the Web page. When the part is selected, a DetailsView control displays all the information about the part and allows the user to edit the part. Which Web control is the best choice to display the part number list for this scenario?
A. The DropDownList control
B. The RadioButtonList control
C. The FormView control
D. The TextBox control

ASP.NET 2.0 Interview Questions

24. While developing ASP.NET 2.0 web application you have a DataSet containing a Customer DataTable and an Order DataTable. You want to easily navigate from an Order DataRow to the Customer who placed the order. What object will allow you to easily navigate from the Order to the Customer?

A. The DataColumn object
B. The DataTable object
C. The DataRow object
D. The DataRelation object

25. Which of the following is a requirement when merging modified data into a DataSet?
A. A primary key must be defined on the DataTable objects.
B. The DataSet schemas must match in order to merge.
C. The destination DataSet must be empty prior to merging.
D. A DataSet must be merged into the same DataSet that created it.

26. You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so?
A. Use the Sort method on the DataTable object.
B. Use the DataSet object’s Sort method.
C. Use a DataView object for each sort.
D. Create a DataTable for each sort, using the DataTable object’s Copy method, and then Sort the result.

27. Which of the following ways can you proactively clean up a database connection’s resources?
A. Execute the DbConnection object’s Cleanup method.
B. Execute the DbConnection object’s Close method.
C. Assign Nothing (C# null) to the variable that references the DbConnection object.
D. Create a using block for the DbConnection object.

29. What event can you subscribe to if you want to display information from SQL Print statements?
A. InfoMessage
B. MessageReceived
C. PostedMessage
D. NewInfo

30. To perform asynchronous data access, what must be added to the connection string?
A. BeginExecute=true
B. MultiThreaded=true
C. MultipleActiveResultSets=true
D. Asynchronous=true

31. Which class can be used to create an XML document from scratch?
A. XmlConvert
B. XmlDocument
C. XmlNew
D. XmlSettings

32. Which class can be used to perform data type conversion between .NET data types and XML types?
A. XmlType
B. XmlCast
C. XmlConvert
D. XmlSettings


MORE POST:

SQL Server 2005 Interview Question

A Leader Should Know How to Manage Failure



Resource:

ASP.NET 2.0

Distributed Authoring and Versioning (DAV)

 

http methods

Multipurpose Internet Mail Extensions (MIME) type

PostBack

QueryString

request

response

Web browser

Web Form

Web server

HTML server control

 ViewState

Web server control

ACID properties

connection pooling

 

DataColumn

DataRow

DataTable

DiffGram

Document Object Model (DOM)

 


 

Posted On Thursday, January 10, 2008 7:33 AM | Comments (0) |

Thursday, January 3, 2008

VB.NET and C# Syntax Comparison

VB.NET and C# Syntax Comparison





VB.NET

Program Structure

C#
Imports System

Namespace HelloNamespace
   Class HelloClass
      Overloads Shared Sub Main(ByVal args() As String)
         Dim name As String = "VB.NET"

         'If an argument was passed from the command line
          If args.Length = 1 Then name = args(0)

          Console.WriteLine("Hello, " & name & "!")
      End Sub
   End Class
End Namespace
using System;

namespace HelloNamespace {
   public class HelloClass{
      public static void Main(string[] args) {
         string name = "C#";

         // If an argument was passed from the command line
         if (args.Length == 1)
            name = args[0];

         Console.WriteLine("Hello, " + name + "!");
      }
   }
}
VB.NET

Comments

C#
' Single line only

''' <summary>XML comments</summary>

// Single line
/* Multiple
    line  */
/// <summary>XML comments on single line</summary>
/** <summary>XML comments on multiple lines</summary> */

VB.NET

Data Types

C#

Value Types
Boolean
Byte, SByte
Char
Short, UShort, Integer, UInteger, Long, ULong
Single, Double
Decimal
Date

Reference Types
Object
String

Initializing
Dim correct As Boolean = True
Dim b As Byte = &H2A   'hex
Dim o As Byte = &O52   'octal
Dim person As Object = Nothing
Dim name As String = "Dwight"
Dim grade As Char = "B"c
Dim today As Date = #12/31/2007 12:15:00 PM#
Dim amount As Decimal = 35.99@
Dim gpa As Single = 2.9!
Dim pi As Double = 3.14159265
Dim lTotal As Long = 123456L
Dim sTotal As Short = 123S
Dim usTotal As UShort = 123US
Dim uiTotal As UInteger = 123UI
Dim ulTotal As ULong = 123UL

Type Information
Dim x As Integer
Console.WriteLine(x.GetType())          ' Prints System.Int32
Console.WriteLine(GetType(Integer))   ' Prints System.Int32
Console.WriteLine(TypeName(x))        ' Prints Integer

Type Conversion
Dim d As Single = 3.5
Dim i As Integer = CType(d, Integer)   ' set to 4 (Banker's rounding)
i = CInt(d)  ' same result as CType
i = Int(d)    ' set to 3 (Int function truncates the decimal)

Value Types
bool
byte, sbyte
char
short, ushort, int, uint, long, ulong
float, double
decimal
DateTime   (not a built-in C# type)

Reference Types
object
string

Initializing
bool correct = true;
byte b = 0x2A;   // hex

object person = null;
string name = "Dwight";
char grade = 'B';
DateTime today = DateTime.Parse("12/31/2007 12:15:00");
decimal amount = 35.99m;
float gpa = 2.9f;
double pi = 3.14159265;
long lTotal = 123456L;
short sTotal = 123;
ushort usTotal = 123;
uint uiTotal = 123;
ulong ulTotal = 123;

Type Information
int x;
Console.WriteLine(x.GetType());              // Prints System.Int32
Console.WriteLine(typeof(int));               // Prints System.Int32
Console.WriteLine(x.GetType().Name);   // prints Int32

Type Conversion
float d = 3.5f;
int i = (int)d;   // set to 3  (truncates decimal)

VB.NET

Constants

C#
Const MAX_STUDENTS As Integer = 25

' Can set to a const or var; may be initialized in a constructor
ReadOnly MIN_DIAMETER As Single = 4.93

const int MAX_STUDENTS = 25;

// Can set to a const or var; may be initialized in a constructor
readonly float MIN_DIAMETER = 4.93f;

VB.NET

Enumerations

C#
Enum Action
  Start 
  [Stop]   ' Stop is a reserved word
  Rewind
  Forward
End Enum

Enum Status
  Flunk = 50
  Pass = 70
  Excel = 90
End Enum

Dim a As Action = Action.Stop
If a <> Action.Start Then _
   Console.WriteLine(a.ToString & " is " & a)     ' Prints "Stop is 1"

Console.WriteLine(Status.Pass)     ' Prints 70
Console.WriteLine(Status.Pass.ToString())     ' Prints Pass
enum Action {Start, Stop, Rewind, Forward};
enum Status {Flunk = 50, Pass = 70, Excel = 90};

Action a = Action.Stop;
if (a != Action.Start)
  Console.WriteLine(a + " is " + (int) a);    // Prints "Stop is 1"

Console.WriteLine((int) Status.Pass);    // Prints 70
Console.WriteLine(Status.Pass);      // Prints Pass
VB.NET

Operators

C#

Comparison
=  <  >  <=  >=  <>

Arithmetic
+  -  *  /
Mod
(integer division)
(raise to a power)

Assignment
=  +=  -=  *=  /=  \=  ^=  <<=  >>=  &=

Bitwise
And   Or   Xor   Not   <<   >>

Logical
AndAlso   OrElse   And   Or   Xor   Not

Note: AndAlso and OrElse perform short-circuit logical evaluations

String Concatenation
&

Comparison
==  <  >  <=  >=  !=

Arithmetic
+  -  *  /
(mod)
(integer division if both operands are ints)
Math.Pow(x, y)

Assignment
=  +=  -=  *=  /=   %=  &=  |=  ^=  <<=  >>=  ++  --

Bitwise
&   |   ^   ~   <<   >>

Logical
&&   ||   &   |   ^   !

Note: && and || perform short-circuit logical evaluations

String Concatenation
+

VB.NET

Choices

C#

greeting = IIf(age < 20, "What's up?", "Hello")

' One line doesn't require "End If"
If age < 20 Then greeting = "What's up?"
If age < 20 Then greeting = "What's up?" Else greeting = "Hello"

' Use : to put two commands on same line
If x <> 100 And y < 5 Then x *= 5 : y *= 2  

' Preferred
If x <> 100 And y < 5 Then
  x *= 5
  y *= 2
End If

' To break up any long single line use _
If whenYouHaveAReally < longLine And _
  itNeedsToBeBrokenInto2 > Lines Then _
  UseTheUnderscore(charToBreakItUp)

'If x > 5 Then
  x *= y
ElseIf x = 5 Then
  x += y
ElseIf x < 10 Then
  x -= y
Else
  x /= y
End If

Select Case color   ' Must be a primitive data type
  Case "pink", "red"
    r += 1
  Case "blue"
    b += 1
  Case "green"
    g += 1
  Case Else
    other += 1
End Select

greeting = age < 20 ? "What's up?" : "Hello";

if (age < 20)
  greeting = "What's up?";
else
  greeting = "Hello";

// Multiple statements must be enclosed in {}
if (x != 100 && y < 5) {   
  x *= 5;
  y *= 2;
}



No need for _ or : since ; is used to terminate each statement.





if
(x > 5)
  x *= y;
else if (x == 5)
  x += y;
else if (x < 10)
  x -= y;
else
  x /= y;



// Every case must end with break or goto case
switch (color) {                          // Must be integer or string
  case "pink":
  case "red":    r++;    break;
  case "blue":   b++;   break;
  case "green": g++;   break;
  default:    other++;   break;       // break necessary on default
}

VB.NET

Loops

C#
Pre-test Loops:
While c < 10
  c += 1
End While

Do Until c = 10 
  c += 1
Loop

Do While c < 10
  c += 1
Loop

For c = 2 To 10 Step 2
  Console.WriteLine(c)
Next


Post-test Loops:
Do 
  c += 1
Loop While c < 10
Do 
  c += 1
Loop Until c = 10

'  Array or collection looping
Dim names As String() = {"Fred", "Sue", "Barney"}
For Each s As String In names
  Console.WriteLine(s)
Next

' Breaking out of loops
Dim i As Integer = 0
While (True)
  If (i = 5) Then Exit While
  i += 1
End While


' Continue to next iteration
For i = 0 To 4
  If i < 4 Then Continue For
  Console.WriteLine(i)   ' Only prints 4
Next

Pre-test Loops:  

// no "until" keyword
while (c < 10)
  c++;

for (c = 2; c <= 10; c += 2)
  Console.WriteLine(c);



Post-test Loop:

do
  c++;
while (c < 10);



// Array or collection looping
string[] names = {"Fred", "Sue", "Barney"};
foreach (string s in names)
  Console.WriteLine(s);

// Breaking out of loops
int i = 0;
while (true) {
  if (i == 5)
    break;
  i++;
}

// Continue to next iteration
for (i = 0; i < 5; i++) {
  if (i < 4)
    continue;
  Console.WriteLine(i);   // Only prints 4
}

VB.NET

Arrays

C#

Dim nums() As Integer = {1, 2, 3} 
For i As Integer = 0 To nums.Length - 1
  Console.WriteLine(nums(i))
Next

' 4 is the index of the last element, so it holds 5 elements
Dim names(4) As String
names(0) = "David"
names(5) = "Bobby"  ' Throws System.IndexOutOfRangeException

' Resize the array, keeping the existing values (Preserve is optional)
ReDim Preserve names(6)



Dim twoD(rows-1, cols-1) As Single
twoD(2, 0) = 4.5

Dim jagged()() As Integer = { _
  New Integer(4) {}, New Integer(1) {}, New Integer(2) {} }
jagged(0)(4) = 5

int[] nums = {1, 2, 3};
for (int i = 0; i < nums.Length; i++)
  Console.WriteLine(nums[i]);


// 5 is the size of the array
string[] names = new string[5];
names[0] = "David";
names[5] = "Bobby";   // Throws System.IndexOutOfRangeException


// C# can't dynamically resize an array.  Just copy into new array.
string[] names2 = new string[7];
Array.Copy(names, names2, names.Length);   // or names.CopyTo(names2, 0); 

float[,] twoD = new float[rows, cols];
twoD[2,0] = 4.5f; 

int[][] jagged = new int[3][] {
  new int[5], new int[2], new int[3] };
jagged[0][4] = 5;

VB.NET

Functions

C#

' Pass by value (in, default), reference (in/out), and reference (out) 
Sub TestFunction(ByVal x As Integer, ByRef y As Integer, ByRef z As Integer)
  x += 1
  y += 1
  z = 5
End Sub

Dim a = 1, b = 1, c As Integer   ' c set to zero by default 
TestFunction(a, b, c)
Console.WriteLine("{0} {1} {2}", a, b, c)   ' 1 2 5

' Accept variable number of arguments
Function Sum(ByVal ParamArray nums As Integer()) As Integer
  Sum = 0 
  For Each i As Integer In nums
    Sum += i
  Next
End Function   ' Or use Return statement like C#

Dim total As Integer = Sum(4, 3, 2, 1)   ' returns 10

' Optional parameters must be listed last and must have a default value
Sub SayHello(ByVal name As String, Optional ByVal prefix As String = "")
  Console.WriteLine("Greetings, " & prefix & " " & name)
End Sub

SayHello("Strangelove", "Dr.")
SayHello("Madonna")

// Pass by value (in, default), reference (in/out), and reference (out)
void TestFunction(int x, ref int y, out int z) {
  x++;  
  y++;
  z = 5;
}

int a = 1, b = 1, c;  // c doesn't need initializing
TestFunction(a, ref b, out c);
Console.WriteLine("{0} {1} {2}", a, b, c);  // 1 2 5

// Accept variable number of arguments
int Sum(params int[] nums) {
  int sum = 0;
  foreach (int i in nums)
    sum += i;
  return sum;
}

int total = Sum(4, 3, 2, 1);   // returns 10

/* C# doesn't support optional arguments/parameters.  Just create two different versions of the same function. */ 
void SayHello(string name, string prefix) {
  Console.WriteLine("Greetings, " + prefix + " " + name);


void SayHello(string name) {
  SayHello(name, "");
}

VB.NET

Strings

C#

Special character constants
vbCrLf, vbCr, vbLf, vbNewLine
vbNullString
vbTab
vbBack
vbFormFeed
vbVerticalTab
""

' String concatenation (use & or +)
Dim school As String = "Harding" & vbTab
school = school & "University" ' school is "Harding (tab) University"

' Chars
Dim letter As Char = school.Chars(0)   ' letter is H
letter = Convert.ToChar(65)                ' letter is A
letter = Chr(65)                                 ' same thing
Dim word() As Char = school.ToCharArray() ' word holds Harding

' No string literal operator 
Dim msg As String = "File is c:\temp\x.dat" 



' String comparison
Dim mascot As String = "Bisons"
If (mascot = "Bisons") Then   ' true
If (mascot.Equals("Bisons")) Then   ' true
If (mascot.ToUpper().Equals("BISONS")) Then  ' true
If (mascot.CompareTo("Bisons") = 0) Then   ' true

Console.WriteLine(mascot.Substring(2, 3)) ' Prints "son"

' String matching
If ("John 3:16" Like "Jo[Hh]? #:*") Then   'true

Imports System.Text.RegularExpressions   ' More powerful than Like
Dim r As New Regex("Jo[hH]. \d:*")
If (r.Match("John 3:16").Success) Then   'true

' My birthday: Oct 12, 1973
Dim dt As New DateTime(1973, 10, 12)
Dim s As String = "My birthday: " & dt.ToString("MMM dd, yyyy")

' Mutable string
Dim buffer As New System.Text.StringBuilder("two ")
buffer.Append("three ")
buffer.Insert(0, "one ")
buffer.Replace("two", "TWO")
Console.WriteLine(buffer)         ' Prints "one TWO three"

Escape sequences
\r    // carriage-return
\n    // line-feed
\t    // tab
\\    // backslash
\"    // quote




// String concatenation
string school = "Harding\t";
school = school + "University";   // school is "Harding (tab) University"

// Chars
char letter = school[0];            // letter is H
letter = Convert.ToChar(65);     // letter is A
letter = (char)65;                    // same thing
char[] word = school.ToCharArray();   // word holds Harding

// String literal
string msg = @"File is c:\temp\x.dat";
// same as
string msg = "File is c:\\temp\\x.dat";

// String comparison
string mascot = "Bisons";
if (mascot == "Bisons")    // true
if (mascot.Equals("Bisons"))   // true
if (mascot.ToUpper().Equals("BISONS"))   // true
if (mascot.CompareTo("Bisons") == 0)    // true

Console.WriteLine(mascot.Substring(2, 3));    // Prints "son"

// String matching
// No Like equivalent - use regular expressions


using System.Text.RegularExpressions;
Regex r = new Regex(@"Jo[hH]. \d:*");
if (r.Match("John 3:16").Success)   // true

// My birthday: Oct 12, 1973
DateTime dt = new DateTime(1973, 10, 12);
string s = "My birthday: " + dt.ToString("MMM dd, yyyy");

// Mutable string
System.Text.StringBuilder buffer = new System.Text.StringBuilder("two ");
buffer.Append("three ");
buffer.Insert(0, "one ");
buffer.Replace("two", "TWO");
Console.WriteLine(buffer);     // Prints "one TWO three"

VB.NET

Exception Handling

C#

' Throw an exception
Dim ex As New Exception("Something is really wrong.")
Throw  ex 

' Catch an exception
Try 
  y = 0
  x = 10 / y
Catch ex As Exception When y = 0 ' Argument and When is optional
  Console.WriteLine(ex.Message)
Finally
  Beep()
End Try

' Deprecated unstructured error handling
On Error GoTo MyErrorHandler
...
MyErrorHandler: Console.WriteLine(Err.Description)

// Throw an exception
Exception up = new Exception("Something is really wrong.");
throw up;  // ha ha

// Catch an exception
try
  y = 0;
  x = 10 / y;
}
catch (Exception ex) {   // Argument is optional, no "When" keyword 
  Console.WriteLine(ex.Message);
}
finally {
  // Requires reference to the Microsoft.VisualBasic.dll
  // assembly (pre .NET Framework v2.0)

  Microsoft.VisualBasic.Interaction.Beep();
}

VB.NET

Namespaces

C#

Namespace MyCompany.Product 
  ...
End Namespace

' or

Namespace MyCompany
  Namespace Product 
   
      ...
   
  End Namespace
End Namespace

Imports MyCompany.Product

namespace MyCompany.Product {
  ...
}

// or

namespace MyCompany{
  namespace Product {
    
      ...
    
  }
}

using MyCompany.Product;

VB.NET

Classes / Interfaces

C#

Accessibility keywords
Public
Private
Friend                   
Protected
Protected Friend
Shared

' Inheritance
Class Game
  Inherits Competition
  ...
End Class 

' Interface definition
Interface IAlarmClock 
  ...
End Interface

// Extending an interface 
Interface IAlarmClock
  Inherits IClock
  ...
End Interface

// Interface implementation
Class WristWatch 
  Implements IAlarmClock, ITimer 
   ...
End Class 

Accessibility keywords
public
private
internal
protected
protected internal
static

// Inheritance
class Game : Competition {
  ...
}


// Interface definition

interface IAlarmClock {
  ...
}

// Extending an interface 
interface IAlarmClock : IClock {
  ...
}


// Interface implementation

class WristWatch : IAlarmClock, ITimer {
   ...
}

VB.NET

Constructors / Destructors

C#
Class SuperHero
  Private _powerLevel As Integer

  Public Sub New()
    _powerLevel = 0
  End Sub

  Public Sub New(ByVal powerLevel As Integer)
    Me._powerLevel = powerLevel
  End Sub

  Protected Overrides Sub Finalize() 
   ' Desctructor code to free unmanaged resources
    MyBase.Finalize()
  End Sub
End Class

class SuperHero {
  private int _powerLevel;

  public SuperHero() {
     _powerLevel = 0;
  }

  public SuperHero(int powerLevel) {
    this._powerLevel= powerLevel; 
  }

  ~SuperHero() {
    // Destructor code to free unmanaged resources.
    // Implicitly creates a Finalize method

  }
}

VB.NET

Using Objects

C#

Dim hero As SuperHero = New SuperHero
' or
Dim hero As New SuperHero

With hero
  .Name = "SpamMan"
  .PowerLevel = 3
End With

hero.Defend("Laura Jones")
hero.Rest()     ' Calling Shared method
' or
SuperHero.Rest()

Dim hero2 As SuperHero = hero  ' Both reference the same object
hero2.Name = "WormWoman"
Console.WriteLine(hero.Name)   ' Prints WormWoman

hero = Nothing    ' Free the object

If hero Is Nothing Then _
  hero = New SuperHero

Dim obj As Object = New SuperHero
If TypeOf obj Is SuperHero Then _
  Console.WriteLine("Is a SuperHero object.")

' Mark object for quick disposal
Using reader As StreamReader = File.OpenText("test.txt")
  Dim line As String = reader.ReadLine()
  While Not line Is Nothing
    Console.WriteLine(line)
    line = reader.ReadLine()
  End While
End Using

SuperHero hero = new SuperHero();



// No "With" construct
hero.Name = "SpamMan";
hero.PowerLevel = 3;


hero.Defend("Laura Jones");
SuperHero.Rest();   // Calling static method



SuperHero hero2 = hero;   // Both reference the same object
hero2.Name = "WormWoman";
Console.WriteLine(hero.Name);   // Prints WormWoman

hero = null ;   // Free the object

if (hero == null)
  hero = new SuperHero();

Object obj = new SuperHero(); 
if (obj is SuperHero)
  Console.WriteLine("Is a SuperHero object.");

// Mark object for quick disposal
using (StreamReader reader = File.OpenText("test.txt")) {
  string line;
  while ((line = reader.ReadLine()) != null)
    Console.WriteLine(line);
}
VB.NET

Structs

C#

Structure StudentRecord
  Public name As String
  Public gpa As Single

  Public Sub New(ByVal name As String, ByVal gpa As Single)
    Me.name = name
    Me.gpa = gpa
  End Sub
End Structure

Dim stu As StudentRecord = New StudentRecord("Bob", 3.5)
Dim stu2 As StudentRecord = stu  

stu2.name = "Sue"
Console.WriteLine(stu.name)    ' Prints Bob
Console.WriteLine(stu2.name)  ' Prints Sue

struct StudentRecord {
  public string name;
  public float gpa;

  public StudentRecord(string name, float gpa) {
    this.name = name;
    this.gpa = gpa;
  }
}

StudentRecord stu = new StudentRecord("Bob", 3.5f);
StudentRecord stu2 = stu;  

stu2.name = "Sue";
Console.WriteLine(stu.name);    // Prints Bob
Console.WriteLine(stu2.name);   // Prints Sue

VB.NET

Properties

C#

Private _size As Integer

Public Property Size() As Integer
  Get
    Return _size
  End Get
  Set (ByVal Value As Integer)
    If Value < 0 Then
      _size = 0
    Else
      _size = Value
    End If
  End Set
End Property

foo.Size += 1

private int _size;

public int Size {
  get {
    return _size;
  }
  set {
    if (value < 0)
      _size = 0;
    else
      _size = value;
  }
}


foo.Size++;

VB.NET

Delegates / Events

C#

Delegate Sub MsgArrivedEventHandler(ByVal message As String)

Event MsgArrivedEvent As MsgArrivedEventHandler

' or to define an event which declares a delegate implicitly
Event MsgArrivedEvent(ByVal message As String)

AddHandler MsgArrivedEvent, AddressOf My_MsgArrivedCallback
' Won't throw an exception if obj is Nothing
RaiseEvent MsgArrivedEvent("Test message")
RemoveHandler MsgArrivedEvent, AddressOf My_MsgArrivedCallback

Imports System.Windows.Forms

Dim WithEvents MyButton As Button   ' WithEvents can't be used on local variable
MyButton = New Button

Private Sub MyButton_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles MyButton.Click
  MessageBox.Show(Me, "Button was clicked", "Info", _
    MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

delegate void MsgArrivedEventHandler(string message);

event MsgArrivedEventHandler MsgArrivedEvent;

// Delegates must be used with events in C#


MsgArrivedEvent += new MsgArrivedEventHandler(My_MsgArrivedEventCallback);
MsgArrivedEvent("Test message");    // Throws exception if obj is null
MsgArrivedEvent -= new MsgArrivedEventHandler(My_MsgArrivedEventCallback);



using System.Windows.Forms;

Button MyButton = new Button(); 
MyButton.Click += new System.EventHandler(MyButton_Click);

private void MyButton_Click(object sender, System.EventArgs e) {
  MessageBox.Show(this, "Button was clicked", "Info",
    MessageBoxButtons.OK, MessageBoxIcon.Information);
}

VB.NET

Console I/O

C#

Console.Write("What's your name? ")
Dim name As String = Console.ReadLine()
Console.Write("How old are you? ")
Dim age As Integer = Val(Console.ReadLine())
Console.WriteLine("{0} is {1} years old.", name, age) 
' or
Console.WriteLine(name & " is " & age & " years old.")

Dim c As Integer
c = Console.Read()    ' Read single char
Console.WriteLine(c)   ' Prints 65 if user enters "A"

Console.Write("What's your name? ");
string name = Console.ReadLine();
Console.Write("How old are you? ");
int age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0} is {1} years old.", name, age);
// or
Console.WriteLine(name + " is " + age + " years old.");


int c = Console.Read();  // Read single char
Console.WriteLine(c);    // Prints 65 if user enters "A"

VB.NET

File I/O

C#

Imports System.IO

' Write out to text file
Dim writer As StreamWriter = File.CreateText("c:\myfile.txt")
writer.WriteLine("Out to file.")
writer.Close()

' Read all lines from text file
Dim reader As StreamReader = File.OpenText("c:\myfile.txt")
Dim line As String = reader.ReadLine()
While Not line Is Nothing
  Console.WriteLine(line)
  line = reader.ReadLine()
End While
reader.Close()

' Write out to binary file
Dim str As String = "Text data"
Dim num As Integer = 123
Dim binWriter As New BinaryWriter(File.OpenWrite("c:\myfile.dat")) 
binWriter.Write(str) 
binWriter.Write(num) 
binWriter.Close()

' Read from binary file
Dim binReader As New BinaryReader(File.OpenRead("c:\myfile.dat"))
str = binReader.ReadString()
num = binReader.ReadInt32()
binReader.Close()

using System.IO;

// Write out to text file
StreamWriter writer = File.CreateText("c:\\myfile.txt");
writer.WriteLine("Out to file.");
writer.Close();

// Read all lines from text file
StreamReader reader = File.OpenText("c:\\myfile.txt");
string line = reader.ReadLine();
while (line != null) {
  Console.WriteLine(line);
  line = reader.ReadLine();
}
reader.Close();

// Write out to binary file
string str = "Text data";
int num = 123;
BinaryWriter binWriter = new BinaryWriter(File.OpenWrite("c:\\myfile.dat"));
binWriter.Write(str);
binWriter.Write(num);
binWriter.Close();

// Read from binary file
BinaryReader binReader = new BinaryReader(File.OpenRead("c:\\myfile.dat"));
str = binReader.ReadString();
num = binReader.ReadInt32();
binReader.Close();

 

 

Source:    http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

Posted On Thursday, January 3, 2008 6:51 PM | Comments (0) |

Thursday, December 27, 2007

ASP.NET TextBox MultiLine maxlength

ASP.NET textbox multiline maxlength

multiline textbox with maxlength in asp.net

According to msdn in ASP.NET you can not use textbox’s MaxLength property with Multiline Mode. But I was required in my current application. So I search google and other search engines and finally got few solution. I am simply compiling all of the solutions in single post.
Solution Number 1 for

ASP.NET TextBox.MultiLine maxlength

Add following javascript

function Count(text,long)

 

{

 

      var maxlength = new Number(long); // Change number to your max length.

 

if(document.getElementById('<%=textBox.ClientID%>').value.length > maxlength){

 

            text.value = text.value.substring(0,maxlength);

 

            alert(" Only " + long + " chars");

 

}

 


Where “textBox” is the asp text box ID.
Also add following events in your textbox.

onKeyUp="javascript:Count(this,200);" onChange="javascript:Count(this,200);"


Your textbox code should look like

 

<asp:TextBox ID="textBox" onKeyUp="javascript:Count(this,2);" onChange="javascript:Count(this,2);"  TextMode=MultiLine Columns="5" Rows="5" runat=server>

    </asp:TextBox>

 


Solution Number 2 for

 

ASP.NET TextBox.MultiLine maxlength

Another way to achieve this is regular expression. You can add following regular expression validate on asp text box.

<asp:RegularExpressionValidator ID="txtConclusionValidator1" ControlToValidate="textBox" Text="Exceeding 200 characters" ValidationExpression="^[\s\S]{0,2}$" runat="server" />



Hope this helps you!!!

Related Post:

Association, Aggregation, Composition object relationship

Talent vs Attitude – Harsha Bhogle

What we can learn from Babies

 

Posted On Thursday, December 27, 2007 11:41 PM | Comments (1) |

Mutex Could not be Created.

Mutex Could not be Created.

Some time while running ASP.NET web application through Visual Studio you might receive following error

Server Error in Application. Mutex could not be created.

Few workaround for “Mutex Could not be Created.”


“Mutex Could not be Created.”

Solution number 1
1. If your visual studio 2005 is open, closed it.
2. Go to the ASP.NET temporary folder for v2.0 of the framework
\Microsoft.Net\Framework\v2.0\Temporary ASpNET pages 3. Remove the folder for your application
4. Reset IIS (iisreset)
5. First Browse your page from Browser
6. Re-open Visual studio
<

“Mutex Could not be Created.”

Solution number 2
1. locate the current machine config file (e.g at C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CONFIG\)
2. update the Machine.Config under the tag like that -

“Mutex Could not be Created.”

Solution number 3
Cause: This occurs because the permissions on the following registry key no longer have your custom account:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\CompilationMutexName
The compilation mutex gets it's permissions from this registry key and with your custom account missing, the process running ASP.NET cannot get a handle to the mutex and fails during compilation.
Resolution:
=========
1. Run the following to add your custom account to the registry key permissions:
ASPNET_regiis -ga domain\account.
2. Either restart the server or close the handles to the mutex (see below)
To close the handles to the Mutex:
3. Download and launch Process Explorer from www.sysinternals.com
4. From the Find menu, select Find Handle or DLL
5. In the Handle or DLL substring box, type “mutant” (without quotes) and click Search
6. Click the Handle or DLL column heading to sort the items and find a mutex that starts with CL. The handle will typically be devenv.exe (the IDE for Visual Studio) and aspnet_wp.exe or w3wp.exe. The handle will look similar to:
7. \BaseNameObjects\CLbdd6aa8f
8. Select the handle in the search box and Process Explorer locates the Process and the handle in the main window
9. Right-click the handle in the main window and select Close Handle
Additional Info:
============
The error may occur anytime you run ASP.NET as a custom account and the above mentioned registry key does not have the account listed in the permissions.
If you receive the error and you are running with a custom account on IIS 6 in worker process mode (code running in w3wp.exe), you can add your custom account to the IIS_WPG group on the server. The IIS_WPG group is granted access to the registry key by default.


“Mutex Could not be Created.”

Solution Number 4
You may also need to fix the perimssions manually, as follows:
1. Run Registry Editor 32: Windows -> Run -> "REGEDT32"
2. Locate the sub-window "HKEY_LOCAL_MACHINE on Local Machine"
3. Navigate to the key:
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\"
(and select it).
4. Click the menu "Security" then "Permissions".
5. Ensure the custom account you are using to run aspnet (e.g. "mydomain\aspnet") is in this permissions list.
If it is not then Add it and ensure "Full Control" is ticked, then click OK.
6. This should immediately resolve the Mutex locking issue (just refresh your page, or rebuild in Visual Studio).
7. If not then do an IISRESET first then retry step 6.


“Mutex Could not be Created.”

Solution number 5
Go to the Visual Studio Command Prompt and reach at
c:\Windows\Microsoft.net\Framework\v2.0.50727>
and type the command
c:\Windows\Microsoft.net\Framework\v2.0.50727> aspnet_regiis -ga Domain\User
After that, go to the windows\microsoft.net\framework\v2.0.50727 and there you'll get a temporary file. Just delete it without any hasitation. Rfresh and restart the IIS.



“Mutex Could not be Created.”

Solution number 6 On Vista Business 1. Delete my app from the aspnet folder
2. Opened Regedit. Went to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.050727.0. Right clicked and added aspnet as user providing it full-control permissions.
Hope this help!!!....

Posted On Thursday, December 27, 2007 6:28 AM | Comments (0) |

Wednesday, December 26, 2007

Items collection cannot be modified when the DataSource property is set.

Items collection cannot be modified when the DataSource property is set.

This exception

“Items collection cannot be modified when the DataSource property is set.”

occurs when you trying to add some text like “Select” or “None” in combo box (drop down list) in .NET framework window form control. There is no such way to add items in combo box’s items property after you set DataSource. To avoid this you can add one more item in your datasource. For example if you are trying to bind drop down list through DataSet then add one more row into DataSet. There is one more workaround for

“Items collection cannot be modified when the DataSource property is set.”


Related Post:

Association, Aggregation, Composition object relationship

Talent vs Attitude – Harsha Bhogle

What we can learn from Babies

 

Posted On Wednesday, December 26, 2007 7:59 PM | Comments (1) |

Tuesday, December 25, 2007

ASP.NET Web Services Interview Questions

ASP.NET Web Services Interview Questions



Which page is used to display the link of webmethods in ASP.NET web services?

If your webmethod is having return type is void and while consuming the webservices you don’t want to wait the complete execution to that method. How would you achive this?

How you would make your web services to participate in transaction?

What would be key requirement to make ASP.NET web application an ASP.NET Web Services?

What is the primary purpose of Namespace property, which is used in WebServices attribute?

Identify invalid WebServices declaration?

While creating Web Service through visual studio template, which namespaces are include automatically?

Posted On Tuesday, December 25, 2007 3:19 AM | Comments (0) |

ASP.NET Web Services Interview Questions

ASP.NET Web Services Interview Questions



Which method is used to serialize an object into an XML document from Xmlserializer class?

How to specify the Web Service compile with the WS-I basic profile?

For SOAP (Simple Object Access Protocol) message formatting what is the purpose of Encoded value?

What are the three main section of SOAP (Simple Object Access Protocol) message?

What all steps are required to create an application to test your ASP.NET web services?

How you can verify the result of your ASP.NET web services?




Posted On Tuesday, December 25, 2007 3:18 AM | Comments (0) |

ASP.NET Web Services Interview Questions

ASP.NET Web Services Interview Questions

How do you configure the SOAP (Simple Object Access Protocol) to associate with particular web method?

Which method of SoapExtension class is used to intercept the incoming stream and determine the stage?

Which is a true statement for BeforeSerialize stage of an in-coming request message occurs?

What value can be used when setting the direction of the SOAP header?

Which is not the step to create custom SOAP (Simple Object Access Protocol) header class?

What kind of information included in SOAP (Simple Object Access Protocol) header?







Posted On Tuesday, December 25, 2007 3:18 AM | Comments (0) |

ASP.NET Web Services Quiz

ASP.NET Web Services Quiz



Which page is used to display the link of webmethods in ASP.NET web services?

If your webmethod is having return type is void and while consuming the webservices you don’t want to wait the complete execution to that method. How would you achive this?

How you would make your web services to participate in transaction?

What would be key requirement to make ASP.NET web application an ASP.NET Web Services?

What is the primary purpose of Namespace property, which is used in WebServices attribute?

Identify invalid WebServices declaration?

While creating Web Service through visual studio template, which namespaces are include automatically?

 

Thanks
~Mahesh




Posted On Tuesday, December 25, 2007 3:11 AM | Comments (1) |

ASP.NET Web Services Quiz

ASP.NET Web Services Quiz



Which method is used to serialize an object into an XML document from Xmlserializer class?

How to specify the Web Service compile with the WS-I basic profile?

For SOAP (Simple Object Access Protocol) message formatting what is the purpose of Encoded value?

What are the three main section of SOAP (Simple Object Access Protocol) message?

What all steps are required to create an application to test your ASP.NET web services?

How you can verify the result of your ASP.NET web services?

Thanks
~Mahesh


Posted On Tuesday, December 25, 2007 3:10 AM | Comments (0) |

ASP.NET Web Services Quiz

ASP.NET Web Services Quiz

How do you configure the SOAP (Simple Object Access Protocol) to associate with particular web method?

Which method of SoapExtension class is used to intercept the incoming stream and determine the stage?

Which is a true statement for BeforeSerialize stage of an in-coming request message occurs?

What value can be used when setting the direction of the SOAP header?

Which is not the step to create custom SOAP (Simple Object Access Protocol) header class?

What kind of information included in SOAP (Simple Object Access Protocol) header?

Thanks
~Mahesh




Posted On Tuesday, December 25, 2007 3:09 AM | Comments (0) |

Sunday, December 23, 2007

ASP.NET Interview Questions

1. What’s the difference between Response.Write() and Response.Output.Write()?

2. What is the sequence of event firing during page load of asp.net page life cycle?

3. For intranet based Web application reads comma-delimited text files. The files reside in a subdirectory root directory. Users are not allowed to navigate directly to these files in a Web browser unless they are members of the Accounting role. You need to write an ASP.NET HTTP handler that will use the FileAuthorizationModule class. What type of authentication you will implement.

4. You company gives you a task to secure existing ASP.NET Web site by redirecting all users to the logon page, Login.aspx. After logging on, users must be redirect to the page that they originally requested. Which should you use?

5. In ASP.NET web application you are creating a Web Form. This Web Form allows users to log on to a Web site which use a Login control named Login1. Membership data for the application is stored in a SQL Express database and .mdf file is in the App_Data directory. In ASP.NET web application you have to configure your application so that the membership data is stored in a local Microsoft SQL Server database. You have following setting in the Web.config file. Which else should you perform?


Posted On Sunday, December 23, 2007 6:22 PM | Comments (0) |

Wednesday, August 8, 2007

Nice VS 2008 Code Editing Improvements

Check it out Scott's new post
http://weblogs.asp.net/scottgu/archive/2007/07/28/nice-vs-2008-code-editing-improvements.aspx

ASP.NET Interview Questions | C# Interview Questions | .NET Interview Questions | Dot Net Interview Questions | VB.NET Interview Questions | Oracle Interview Questions

Posted On Wednesday, August 8, 2007 6:01 PM | Comments (0) |

Friday, July 27, 2007

Thinkinterview Launched!!!

Hi
     Today http://www.thinkinterview.com launched.
Thanks
Mahesh

Posted On Friday, July 27, 2007 8:10 AM | Comments (0) |

Thursday, April 19, 2007

BizTalk Questions Part-1

Hi,
     I am going to start quiz on BizTalk.
In first part I am putting question related to Schema.
You can answer these questions in comment section and letter on I’ll update this blog entry with the appropriate answer with the name of sender.
 So let’s start the knowledge train…
 
  1. What is BizTalk?
  2. How can you reuse existing schema?
  3. What is properties promotion?
  4. Type of properties promotion.
  5. Instance Specific properties VS System or Exchange Specific Properties.
  6. What is Envelop?
  7. What is Message Type in BizTalk?
  8. Promoted Properties VS Distinguished Fields.
  9. “MessageContextPropertiesBase” vs  “MessageDataPropertiesBase”.
  10. How to access Promoted Properties and Distinguished Fields?

Thanks

Mahesh


 


 



ASP.NET Interview Questions | C# Interview Questions | .NET Interview Questions | Dot Net Interview Questions | VB.NET Interview Questions | Oracle Interview Questions

Posted On Thursday, April 19, 2007 6:13 AM | Comments (0) |

Wednesday, July 5, 2006

Abstract Class vs Interface


Introduction:

                        There are lost of discussion on the internet about the Interface vs Abstract class. Also, as base class whether we have to use interface, abstract class or normal class.

 I am trying to point out few considerations on which we can take decision about Interface vs Abstract class vs Class.

 

Abstract Class vs Interface

I am assuming you are having all the basic knowledge of abstract and interface keyword. I am just briefing the basics.

We can not make instance of Abstract Class as well as Interface.

Here are few differences in Abstract class and Interface as per the definition.

Abstract class can contain abstract methods, abstract property as well as other members (just like normal class).

Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract.

 

            //Abstarct Class

public abstract class Vehicles

      {

        private int noOfWheel;

        private string color;

        public abstract string Engine

        {  

            get;

            set;

        }

        public abstract void Accelerator();

      }

      //Interface

public interface Vehicles

      {

        string Engine

        {  

            get;

            set;

        }

        void Accelerator();

      }

 

We can see abstract class contains private members also we can put some methods with implementation also. But in case of interface only methods and properties allowed.

We use abstract class and Interface for the base class in our application.

 

This is all about the language defination. Now million doller question:

How can we take decision about when we have to use Interface and when Abstract Class.

Basicly abstact class is a abstract view of any realword entity and interface is more abstract one. When we thinking about the entity there are two things one is intention and one is implemntation. Intention means I know about the entity and  also may have idea about its state as well as behaviour but don’t know about how its looks or works or may know partially. Implementation means actual state and behaviour of entity.  

Enough theory lets take an example.

I am trying to make a Content Management System where content is a genralize form of article, reviews, blogs etc.

                                   

 

CONTENT

ARTICLE

BLOGS

REVIEW

 

So content is our base class now how we make a decision whether content class should be Abstract class, Interface or normal class.

First normal class vs other type (abstract and interface). If content is not a core entity of my application means as per the business logic if content is nothing in my application only Article, Blogs, Review are the core part of business logic then content class should not be a normal class  because I’ll never make instance of that class. So if you will never make instance of base class then Abstract class and Interface are the more appropriate choice.

Second between Interface and Abstract Class.

CONTENT

Publish ()

ARTICLE

BLOGS

REVIEW

As you can see content having behavior named “Publish”. If according to my business logic Publish having some default behavior which apply to all I’ll prefer content class as an Abstract class. If there is no default behavior for the “Publish” and every drive class makes their own implementation then there is no need to implement “Publish” behavior in  the base case I’ll prefer Interface.

These are the in general idea of taking decision between abstract class, interface and normal class. But there is one catch. As we all know there is one constant in software that is “CHANGE”. If I made content class as Interface then it is difficult to make changes in base class because if I add new method or property in content interface then I have to implement new method in every drive class. These problems will over come if you are using abstract class for content class and new method is not an abstract type. So we can replace interface with abstract class except multiple inheritance.

CAN-DO and IS-A relationship is also define the deference between Interface and abstract class. As we already discuss Interface can be use for multiple inheritance for example we have another interface named “ICopy” which having behavior copy and every drive class have to implements its own implementation of Copy. If “Article” class drive from abstract class Content as well as ICopy then article “CAN-DO” copy also.

IS-A is for “generalization” and “specialization” means content is a generalize form of Article, Blogs, Review and Article, Blogs, Review are a specialize form of Content.

So, abstract class defines core identity. If we are thinking in term of speed then abstract is fast then interface because interface requires extra in-direction.

So as per my view Abstract class having upper-hand in compare to interface. Using  interface having only advantage of multiple inheritance. If you don’t understand the things then don’t worry because it’s my mistake because I am not able to describe the topic.

 


Related Post:

Association, Aggregation, Composition

Talent vs Attitude – Harsha Bhogle

Does writing good content is good enough for reaching out people

 

Posted On Wednesday, July 5, 2006 10:38 AM | Comments (47) |

Thursday, November 30, 2006

Windows PowerShell

Windows PowerShell is a new shell scripting interface built on the Microsoft .NET framework that enables IT Pros and .NET developers to control and automate the administration of Windows and applications. It uses a new admin-focused scripting language and features more than 130 standard command-line tools.

 Download Windows PowerShell 1.0

Getting Started Guide and Quick Reference sheet

 PowerShell blog

Cheers!!!

Mahesh


ASP.NET Interview Questions | C# Interview Questions | .NET Interview Questions | Dot Net Interview Questions | VB.NET Interview Questions | Oracle Interview Questions

Posted On Thursday, November 30, 2006 8:49 AM | Comments (0) |

Friday, November 24, 2006

Amazing AD on Gandhi Ji

It took Italians to make this one!

Pls click the link below to see the video.

Superb Advertisement- shows popularity and respect to Gandhiji,

A great ad.... Ironically from a non- Indian company!!

And none the less This ad won the EPICA awards for best ad.

 

http://www.epica-awards.org/assets/epica/2004/winners/film/flv/11071.htm

 

Cheers!!!

Mahesh


ASP.NET Interview Questions | C# Interview Questions | .NET Interview Questions | Dot Net Interview Questions | VB.NET Interview Questions | Oracle Interview Questions

Posted On Friday, November 24, 2006 7:05 AM | Comments (0) |

Thursday, November 23, 2006

Metcalfe's law - Fundamental Law of Information Technology

Metcalfe law is one of the fundamental laws of information technology. He explains his law with the example of Fax machine. He explained: there is no use of single or un-connected fax machine. When fax machine connected with other fax machine its values grows is about squire proportional to the no of connection.

 

http://en.wikipedia.org/wiki/Metcalfe's_law

 

Cheers!!!

Mahesh


ASP.NET Interview Questions | C# Interview Questions | .NET Interview Questions | Dot Net Interview Questions | VB.NET Interview Questions | Oracle Interview Questions

Posted On Thursday, November 23, 2006 11:48 AM | Comments (0) |

Monday, October 9, 2006

How to organize projects in .NET Application

 

.NET having solution files, project files and web project.

Solution file can contains multiple project files as well as web project.

Few days back I had to start building new .NET based application. I found few good things and try to share.

 

First of all I am having multiple projects in the solution.

Logical layers for my  web application are:

(user) -> UI -> [AL -> BLL -> DAL] -> (DB)
                              [   -> DTOs        ]
                              [   -> ES             ]

  • UI = User interface
  • AL = Application layer (handlers, as web pages and web services)
  • BLL = Business logic layer (business logic + domain objects)
  • DAL = Data access layer (wrap DB and map data to entities and back)
  • DTOs = Data transfer objects (Mapped to DB entity) referenced by BL and DAL.
  • ES = External services

Cheers

Mahesh

maheshsingh21@hotmail.com





Posted On Monday, October 9, 2006 11:35 AM |

Powered by: