Saturday, July 20, 2013

SQL Server & Vb.net Tips

Software for Catching Flash(.swf) from Websites
1) Flash catcher
2) Flash Saver
----------------------------------------------------------------------------------------------------------------------------------
1. How to enable the mnemonics (underline) being displayed when an application is launched?
Usually the underline appears only after you press the Alt Key, but you can enable it by changing the Operating System Settings. On Windows XP, Right Click Desktop to bring up the Display Properties Dialog and then choose Appearance tab and then the Effects Button and uncheck the checkbox "Hide Underlined letters for keyboard navigation until I press the ALT Key".
----------------------------------------------------------------------------------------------------------------------------------
2. An easy way to build connection string.
Though this in not related to .NET directly but it is useful while working with ADO.NET
Collapse1) Open a New notepad and save it with "udl" extension, suppose "New.udl".2) Now you will see that it's icon is changed.3) Open it, you will find Data Link properties dialog box.4) For SQl Server connection string select Microsoft OLE DB Provider For SQL Server in Provider Tab.5) Click button "Next" or select Connection Tab6) Here you can select all connection details and press button Test Connection. If it is successful close this dialog box.7) Now open this file using "Notepad", you will find the connection string. Though it is built for OLE DB type of connection, you can use for SQL Server connection by removing Provider attribute. NOTE: If you are using SQL Authentication with password, then check the checkbox Allow Saving Password.This is necessary so that password appears in connection string.
----------------------------------------------------------------------------------------------------------------------------------
3. How to add a custom or destination folder to SendTo menu?
Every one knows about SendTo menu that appears after right click on any file.By default there are 4 options or destinations in this menu. But you can add custom destinations to this menu. Adding other locations to the Send To menu is convenient if you frequently perform the same file management tasks. For example, if you back up files on another network computer or on same machine where you have to navigate through a deep path every day, having the computer on the Send To menu can save you time.
To add a destination to the Send To menu follow the steps given below:
Open My Computer.
Double-click the drive where Windows is installed (usually drive C, unless you have more than one drive on your computer). If you can't see the items on your drive when you open it, under System Tasks, click Show the contents of this drive.
Double-click the Documents and Settings folder.
Double-click the folder of a specific user.
Double-click the SendTo folder. The SendTo folder is hidden by default. If it is not visible, on the Tools menu, click Folder Options. On the View tab, click Show hidden files and folders.
On the File menu, point to New, and then click Shortcut.
Follow the instructions on your screen.
----------------------------------------------------------------------------------------------------------------------------------
4)Read a text fileThe following sample code uses a StreamReader class to read the System.ini file. The contents of the file are added to a ListBox control. The try...catch block is used to alert the program if the file is empty. There are many ways to determine when the end of the file is reached; this sample uses the Peek method to examine the next line before reading it.

Dim reader As StreamReader = _ New StreamReader(winDir & "\system.ini") Try Me.ListBox1.Items.Clear() Do Me.ListBox1.Items.Add(reader.ReadLine) Loop Until reader.Peek = -1 Catch Me.ListBox1.Items.Add("File is empty") Finally reader.Close() End Try
----------------------------------------------------------------------------------------------------------------------------------

5)Write a text fileThis sample code uses a StreamWriter class to create and write to a file. If you have an existing file, you can open it in the same way.
Dim writer As StreamWriter = _ New StreamWriter("c:\KBTest.txt") writer.WriteLine("File created using StreamWriter class.") writer.Close()
----------------------------------------------------------------------------------------------------------------------------------

6) View file informationThis sample code uses a FileInfo object to access a file's properties. Notepad.exe is used in this example. The properties appear in a ListBox control.
Dim FileProps As FileInfo = New FileInfo(winDir & "\notepad.exe") With Me.ListBox1.Items .Clear() .Add("File Name = " & FileProps.FullName) .Add("Creation Time = " & FileProps.CreationTime) .Add("Last Access Time = " & FileProps.LastAccessTime) .Add("Last Write Time = " & FileProps.LastWriteTime) .Add("Size = " & FileProps.Length) End With FileProps = Nothing
----------------------------------------------------------------------------------------------------------------------------------
7) List disk drivesThis sample code uses the Directory and Drive classes to list the logical drives on a system. For this sample, the results appear in a ListBox control.
Dim dirInfo As Directory Dim drive As String Me.ListBox1.Items.Clear() Dim drives() As String = dirInfo.GetLogicalDrives() For Each drive In drives Me.ListBox1.Items.Add(drive) Next
----------------------------------------------------------------------------------------------------------------------------------

8)List subfoldersThis sample code uses the GetDirectories method of the Directory class to get a list of folders.
Dim dir As String Me.ListBox1.Items.Clear() Dim dirs() As String = Directory.GetDirectories(winDir) For Each dir In dirs Me.ListBox1.Items.Add(dir) Next
----------------------------------------------------------------------------------------------------------------------------------

9)List filesThis sample code uses the GetFiles method of the Directory class to get a list of files.
Dim file As String Me.ListBox1.Items.Clear() Dim files() As String = Directory.GetFiles(winDir) For Each file In files Me.ListBox1.Items.Add(file) Next
----------------------------------------------------------------------------------------------------------------------------------
SQL Server
10) Using add linked server for connecting one server to another external Database server
Connecting Another DB with windows authentication
exec sp_addlinkedserver [intranetbd]

Connecting Another DB with User defined authentication Syntax:

EXEC sp_addlinkedsrvlogin 'Accounts', 'false', NULL, 'SQLUser', 'Password'
Ex:
exec sp_addlinkedsrvlogin [intranetbd],false,'qteam','tsms','Hr'

Accessing the DB serverselect DISTINCT c_id from [intranetbd].Hr.dbo.projects

Found under SQL Server 2005
Server objects -> Linked server
----------------------------------------------------------------------------------------------------------------------------------

11. Sub Query – Query within Query
Ex : select * from EMP Where Id not in (SELECT Max(Id) from EMP group by Name) order by name
----------------------------------------------------------------------------------------------------------------------------------

12. Write query to get 10 records (random wise) from Table, with out use DESC and TOP Command.Query :
select (select count(*) from Empwhere Name <= t.Name) as SRNo,* from Emp t where 11<=(select count(*) from Emp where Name <= t.Name)and 20>=(select count(*) from Emp where Name <= t.Name)order by Name ---------------------------------------------------------------------------------------------------------------------------------- 13. Write query to using Having Statement: ->It can be used with group by and aggregate function like avg, sum, max, min, etc,.
Exampleselect count(Name) from Emp group by Name having count(Name)>1
----------------------------------------------------------------------------------------------------------------------------------
14) using Substring and charindex
CHARINDEX SYNTAX CHARINDEX( text to find, text ) => 11 Example CHARINDEX('SQL', 'Microsoft SQL Server') => 11
SUBSTRING SYNTAX
SUBSTRING ( expression , start , length )
Example
SELECT x = SUBSTRING('abcdef', 2, 3) => bcd

Combined Example – 1 :
SELECT SUBSTRING(email, 1, CHARINDEX('@', email) - 1) AS Email
FROM Active_employee_list
Combined Example – 2 :
select left(mail_id,charindex('@',mail_id)-1) from emp_personal

Result : jayavelcs@gmail.com -> jayavelcs
----------------------------------------------------------------------------------------------------------------------------------

15) using Stored ProcedureA stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. Stored procedures reduce network traffic and improve performance.

Ex 1:CREATE PROCEDURE sp_myStoredProcedureASSelect column1, column2 From Table1

Ex2:CREATE PROCEDURE sp_myStoredProcedure @myInput intASSelect column1, column2 From Table1Where column1 = @myInput

Ex3:CREATE PROCEDURE sp_myStoredProcedure @myInput int, @myString varchar(100), @myFloatAS Ex4:CREATE PROCEDURE sp_myInsert @FirstName varchar(20), @LastName varchar(30)AsINSERT INTO Names(FirstName, LastName)values(@FirstName, @LastName)

Alter Procedurealter procedure

Drop procedureDrop procedure

Executing
Exec sp_myStoredProcedure 0, 'This is my string', 3.45
----------------------------------------------------------------------------------------------------------------------------------
16) Conversion format : Here is the output from the above script:
Type 1:

select * from audit_table where convert(datetime,left(actual_audit_date,11))='09/06/2007'
Type 2:
1) CONVERT(CHAR(19),GETDATE()) ==>Feb 5 2003 5:54AM
2) CONVERT(CHAR(8),GETDATE(),10 ) ==>02-05-03
3) CONVERT(CHAR(10),GETDATE(),110) ==>02-05-2003
4) CONVERT(CHAR(11),GETDATE(),106) ==>05 Feb 2003
5) CONVERT(CHAR(9),GETDATE(),6) ==>05 Feb 03
6) CONVERT(CHAR(24),GETDATE(),113) ==>05 Feb 2003 05:54:39:56
----------------------------------------------------------------------------------------------------------------------------------
17) Using Temp table

Creatingcreate table #tableTmp (empid varchar(50))

Insertinginsert into #tableTmp
select emp_id from Bats_Log_Emp_Revenue where txn_name = 'Add Partner Employee'

Using
select @NoTrans = count(distinct empid) from #tableTmp

Deleting
drop table #tableTmp
----------------------------------------------------------------------------------------------------------------------------------
18) Importing data from Excel to SQL Server
Select Database --> Right mouse click -- > Import data.
The wizard starts and it self-driven.

Through programmatically

SELECT * INTO db1.dbo.table1FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Excel Driver (*.xls)};DBQ=c:\book1.xls', 'SELECT * FROM [sheet1$]')
----------------------------------------------------------------------------------------------------------------------------------
19) Executing exe from SQL Server
declare @cmd varchar(8000)
set @cmd = 'cmd.exe /C "D:\Scheduled Tasks\LinuxBackup.exe "'
EXEC xp_cmdshell @cmd
----------------------------------------------------------------------------------------------------------------------------------
20) Shrink Database Log File Size
USE wss_content;
GO

-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE wss_content
SET RECOVERY SIMPLE;
GO

-- Shrink the truncated log file to 100 MB.
DBCC SHRINKFILE (wss_content_Log, 100);
GO

-- Reset the database recovery model.
ALTER DATABASE wss_content
SET RECOVERY FULL;
GO
----------------------------------------------------------------------------------------------------------------------------------
21) String Functions
LEFT(S , N):
Returns the first N characters of string S from the left.
Example: LEFT('Function',6)='Functi'

RIGHT(S , N) : Returns the last N characters of string S from the right.
Example: RIGHT('Function',6)='nction'

LEN (S): Returns the number of characters in string S.
Example: LEN ('Function',6)=8

LOWER (S): Return string S after converting all characters to lower case.
Example: LOWER ('Function')='function'

UPPER (S): Return string S after converting all characters to upper case.
Example: UPPER ('Function')='FUNCTION'

LTRIM (S): Return string S after removing all blank characters from the left.
Example: LTRIM (' Function')='Function'

RTRIM (S): Return string S after removing all blank characters from the right.
Example: RTRIM ('Function ')='Function'

REPLACE ( S1 ,S2 ,S3 ): Return S1 after replacing all occurrence of S2 in it with S3
Example: REPLACE ('Function','n','123')='Fu123ctio123'

REPLICATE ( S , N): Return a repetition of string S, N times
Example: REPLICATE ('abc',3)='abcabcabc'

REVERSE ( S) : Return string S after reversing the order of all characters.
Example: REVERSE ('Function')=' noitcnuF'

SPACE(N): Return a string of repeated spaces N times.
Example: SPACE(4)=' '

STUFF ( S , I, N, S1): Return string S after deleting N characters from index I and inserting S1 at position I.
Example: STUFF ('Function', 3, 4,'abc' )='Fuabcon'

SUBSTRING ( S, I, N): Return a portion of S from index I of N characters.
Example: SUBSTRING ('Function', 3, 4)='ncti'
------------------------------------------------------------------------------------------------------------------------------------------
1) Aggregate FunctionsAVG ( [ ALL DISTINCT ] E ) : Return the average of not null values of expression E. If ALL parameter is specify the function is apply to all values, it is the default value. If DISTINCT parameter is specify the function is apply only on each occurrence of the value.
Example: SELECT HOURS FROM Employee returns (7, 8, 10, 5, 4, 6, 8, 7, 11, 10, 12) SELECT AVG(HOURS) FROM Employee returns (8) SELECT AVG(DISTINCT HOURS) FROM Employee returns (7)

COUNT ( [ ALL DISTINCT ] E ]) : Return the number of item in the group of expression E. If E=* the function will return the number of record in the data source. If ALL parameter is specify the function is apply to all values, it is the default value. If DISTINCT parameter is specify the function is apply only on each occurrence of the value. The parameter ALL and DISTINCT can not be use with *.
MAX(E): Return the maximum value of expression E.
Example: SELECT HOURS FROM Employee returns (7, 8, 10, 5, 4, 6, 8, 7, 11, 10, 12) SELECT MAX(HOURS) FROM Employee return (12)

MIN(E): Return the minimum value of expression E.
Example: SELECT HOURS FROM Employee returns (7, 8, 10, 5, 4, 6, 8, 7, 11, 10, 12)
SELECT MIN(HOURS) FROM Employee return (4)
SUM ( [ ALL DISTINCT ] E): Return the SUM of not null values of expression E. If ALL parameter is specify the function is apply to all values, it is the default value. If DISTINCT parameter is specify the function is apply only on each occurrence of the value. SUM can be use numeric columns only.
Example: SELECT HOURS FROM Employee returns (7, 8, 10, 5, 4, 6, 8, 7, 11, 10, 12) SELECT SUM(HOURS) FROM Employee returns (88) SELECT SUM(DISTINCT HOURS) FROM Employee returns (63)
------------------------------------------------------------------------------------------------------------------------------------------
29) Using Data type Conversations
Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.

Syntax
CAST ( expression AS data_type )
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Ex:CONVERT(decimal(10,5), @myval)
------------------------------------------------------------------------------------------------------------------------------------------
27) Try –Catch

BEGIN TRY
EXEC dbo.sp_bcr_import_data_report
END TRY
BEGIN CATCH
PRINT 'Test';
RETURN;
END CATCH
------------------------------------------------------------------------------------------------------------------------------------------
28) Begin Tran – End Tran

go
begin tran mytrans;
insert into table1 values (1, 'test');
insert into table1 values (1, 'jsaureouwrolsjflseorwurw'); -- it will encounter error here since max value to be inputted is 10
commit tran mytrans;
go

SQL SERVER – Select the Most Optimal Backup Methods for Server

Backup and Restore are very interesting concepts and one should be very much with the concept if you are dealing with production database. One never knows when a natural disaster or user error will surface and the first thing everybody wants is to get back on point in time when things were all fine. Well, in this article I have attempted to answer a few of the common questions related to Backup methodology.
How to Select a SQL Server Backup Type
In order to select a proper SQL Server backup type, a SQL Server administrator needs to understand the difference between the major backup types clearly. Since a picture is worth a thousand words, let me offer it to you below.

Select a Recovery Model First
The very first question that you should ask yourself is: Can I afford to lose at least a little (15 min, 1 hour, 1 day) worth of data? Resist the temptation to save it all as it comes with the overhead – majority of businesses outside finances can actually afford to lose a bit of data.
If your answer is YES, I can afford to lose some data – select a SIMPLE (default) recovery model in the properties of your database, otherwise you need to select a FULL recovery model.
The additional advantage of the Full recovery model is that it allows you to restore the data to a specific point in time vs to only last backup time in the Simple recovery model, but it exceeds the scope of this article
Backups in SIMPLE Recovery Model
In SIMPLE recovery model you can select to do just Full backups or Full + Differential.
Full Backup
This is the simplest type of backup that contains all information needed to restore the database and should be your first choice. It is often sufficient for small databases, but note that it makes a big impact on the performance of your database
Full + Differential Backup
After Full, Differential backup picks up all of the changes since the last Full backup. This means if you made Full, Diff, Diff backup – the last Diff backup contains all of the changes and you don’t need the previous Differential backup. Differential backup is obviously smaller and carries less performance overhead
Backups in FULL Recovery Model
In FULL recovery model you can select Full + Transaction Log or Full + Differential + Transaction Log backup. You have to create Transaction Log backup, because at that time the log is being truncated. Otherwise your Transaction Log will grow uncontrollably.
Full + Transaction Log Backup
You would always need to perform a Full backup first. Then a series of Transaction log backup. Note that (in contrast to Differential) you need ALL transactions to log since the last Full of Diff backup to properly restore. Transaction log backups have the smallest performance overhead and can be performed often.
Full + Differential + Transaction Log Backup
If you want to ease the performance overhead on your server, you can replace some of the Full backup in the previous scenario with Differential. You restore scenario would start from Full, then the Last Differential, then all of the remaining transactions log backups
Typical backup Scenarios
You may say “Well, it is all nice – give me the examples now”. As you mayalready know, my favorite SQL backup software is SQLBackupAndFTP. If you go to Advanced Backup Schedule form in this program and click “Load a typical backup plan…” link, it will give you these scenarios that I think are quite common – see the image below.

The Simplest Way to Schedule SQL Backups
I hate to repeat myself, but backup scheduling in SQL agent leaves a lot to be desired. I do not know the simple way to schedule your SQL server backups than in SQLBackupAndFTP – see the image below. The whole backup scheduling with compression, encryption and upload to a Network Folder / HDD / NAS Drive / FTP / Dropbox / Google Drive / Amazon S3 takes just a few minutes – see my previous post for the review.
Referred URL















http://blog.sqlauthority.com/2012/12/18/sql-server-select-the-most-optimal-backup-methods-for-server/

How to add selection controls to your DataGrid – Dot net 1.1


Source:
http://www.codeproject.com/KB/vb/SelectionCtlsDataGrid.aspx
The attached application contains all the code needed to run. Since some of the columns of the DataGrid are loading through a MS SQL Server � database, you need to change the server settings accordingly (server name, user ID and password).
And run the attached script on the Query Analyzer to create the database on the SQL Server.
//Capturing clicked cell into a locally defined variable.
Private hitTestGrid As DataGrid.HitTestInfo

All the controls which you wish to have on the DataGrid should be declared along "WithEvents" keyword, only if you are interested with their events to be captured.
Private WithEvents datagridtextBox As DataGridTextBoxColumn
Private WithEvents dataTable As dataTable
Private WithEvents comboControl As System.Windows.Forms.ComboBox
Private WithEvents dtp As New DateTimePicker
Private WithEvents chk As New CheckBox

Now we will see about capturing events and getting values to the DataGrid. (This code fragment shows you how to get value form aDateTimePicker and place it on the selected cell.)
Private Sub dtp_ValueChanged(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles dtp.ValueChanged
    dgMember(hitTestGrid.Row, hitTestGrid.Column) = dtp.Value.ToString
End Sub
Looping through available columns and determining on which cell you have clicked:

For i = 0 To dataTable.Rows.Count - 1
    sType = dgMember(i, 0).ToString()
    If hitTestGrid.Row = i Then
        Select Case hitTestGrid.Row
            Case 1
                datagridtextBox.TextBox.Controls.Add(dtp)
                dtp.BringToFront()
            Case 0
                datagridtextBox.TextBox.Controls.Add(comboControl)
                comboControl.BringToFront()
            Case 2
                datagridtextBox.TextBox.Controls.Add(chk)
                chk.BringToFront()
            Case 3
                datagridtextBox.TextBox.Controls.Add(rb)
                rb.BringToFront()
        End Select
    End If
    datagridtextBox.TextBox.BackColor = Color.White
Next i

Please look into the code, by that you will get a better picture about the concept.












http://www.codeproject.com/KB/vb/SelectionCtlsDataGrid/DataGrid.zip

Downloading xml data from web server and reading in C#

Help URL: http://msdn.microsoft.com/fr-fr/library/system.net.webresponse.getresponsestream(VS.80).aspx

// Create a 'WebRequest' object with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://phoenixswsolutions.com/app.xml");

//Credentials for accessing the information
myWebRequest.Credentails = System.Net.CredentailsCache.DeafultCredentails;

// Send the 'WebRequest' and wait for response.WebResponse myWebResponse = myWebRequest.GetResponse();

// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myWebResponse.GetResponseStream();

Encoding encode = System.Text.Encoding.GetEncoding("utf-8");

// Pipe the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( ReceiveStream, encode );

string strResponse=readStream.ReadToEnd();

Console.WriteLine(strResponse);

readStream.Close();

// Release the resources of response object.myWebResponse.Close();

AOP in .NET: Practical Aspect-Oriented Programming

How to prepare for c# and .NETinterviews?

Referred URL - http://dotnetinterviewquestion.wordpress.com/2013/02/11/how-to-prepare-for-c-and-netinterviews/

How to prepare for c# and .NETinterviews?

C# is the flag ship language for giant IT Company Microsoft. Now because it’s a flag ship language of Microsoft, job opportunities are ample in this area. This article will run you through what you should be preparing before going to c# interviews.
clip_image002
This is not a short cut to get a job.
This article is not a short cut to get a position as c# developer. Rather it shows a road map of how you should be preparing yourself, so that you do not end up losing good opportunities.
There is no replacement for experience and knowledge for getting a job as a developer.
But said and done how much ever experienced you are , you need to prepare. Must be you are one of those chosen ones who have worked with APOLLO 13 kind of projects but then you suddenly fail to answer simple questions on OOP like “What is Abstraction ?”.
Remember 90% developers who attend c# interviews do not go prepared and if you go prepared you will certainly stand out in the crowd.
Only C# will lead you no where.
Gone are the days when you just talked about couple of .NET fundamental topics, some OOP (Object oriented programming) questions and few SQL queries and you had job in your hand. Software companies are now looking for c# professionals who can work in a generalized way rather than working on specialized skills.
Below is a simple road map which you can keep in your mind when you prepare from c# and .NET interviews. In the further articles I will be discussing in more details regarding the below road map.

clip_image004
The five pillars of c# interviews
Irrespective you are senior developer or a junior developer, you cannot get away by not answering question from these 5 categories. The five important categories which every c# developer should answer are OOP, .NET fundamentals, ASP.NET, ADO.NET and SQL Server.
The first and top most from these 5 categories is OOP (object oriented programming). Almost 80% of c# interview start from OOP questions. You as a c# developer should not take any kind of risk when it comes to answering OOP question. Not answering OOP question is calling for disqualification right away. Below are some questions which are asked from OOP perspective:-
§   Principles of OOP
§   Abstract VS encapsulation
§   How did you implement encapsulation?
§   Difference between shadowing and overriding?
§   Different types of polymorphism in c#.
The second category is .NET fundamentals. In this section interviewer expects you to know things like delegates, events, garbage collector, reflection etc. As a c# developer everything we develop using .NET framework, so again this is a crucial part of c# interviews. Some most asked questions from .NET fundamental sections which are asked:-
§   CLR, CTS, CAS,IL code etc.
§   Delegates , events , difference between them
§   Reflection,threading, application domain,boxing, unboxing etc.
Again .NET framework has lot of versions and the interviewer will expect that you important features of each version.
The third category of those five pillars which is important is ASP.NET. Almost all software projects are now built as web applications and ASP.NET is the framework for creating web application in Microsoft technology. So again this section becomes compulsory and important. The most favorite questions in ASP.NET revolve around page life cycle, authentication, authorization, sessions, view state and caching. Below goes most common topics for ASP.Net interviews questions:-
§   Page life cycle.
§   Authentication and Authorization
§   Session , cache , view state and applications.
§   Server controls and user controls.
The fourth category is SQL server. RDBMS forms one of the important parts of any software project. SQL Server is the primary RDBMS product. Again this section you need to prepare thoroughly. I have seen many c# interviewers very particular about SQL queries. In this section mostly I have seen interviewer throwing some tricky SQL queries, asking some database design questions and some questions around stored procedures,triggers, views and cursors. Below are some sections which are discussed during SQL server questions:-
§ Database normalization (first normal form, second normal form and third normal form).
§ SQL Joins
§ Triggers, stored procedures, Views and cursors.
§ UNION and UNION ALL.
The fifth section is ADO.NET. ADO.NET is a component which helps us to connect to SQL Server and fetch data in to c# applications. Some of the question which is making rounds in ADO.NET are datareader versus dataset , use of dataview, connection pooling etc. Below are some sections which will help you prepare around ADO.NET:-
§   ADO.NET components
§   Dataset VS datareader
§   Using SP with ADO.NET
§   Locking and connection pooling.
Second level WCF / MVC and EF
If you are more than 3 to 4 years of experience interviewers expects you to answer questions around these 3 sections WCF, MVC and EF.
WCF is one of the most discussed topics when it comes to c# interviewers. If you are a senior this topic is a must in your portfolio. Following are some most frequently asked WCF questions:-
§   Why WCF ?
§   WCF vsWebservicesvsremoting
§   Operation contract, data contract and service contract.
§   One way and two way contracts.
§   Security, Transactions,REST , Instancing etc.
MVC is again one of the must topics when it goes above 3 years of experience. On the contrary after some years I am confident this will be the sixth compulsory pillar for .NET interviews. Again EF can be one of the asked topics. Now EF is not compulsory but depending on job description , it can be a make or break thing.
Optional but can make a difference
C# is vast, so preparing everything is just not possible. There are some optional sections. Again depending on JD (job description) these optional sections can be do or die. In case are dropping these optional sections make sure it’s not a part of the JD.  There are 3 things which can be kept optional:-
§ Business intelligence (SSIS, SSAS and SSRS). Just a thin line here SSRS is not exactly optional. It’s the prime reporting tool of MS. Ensure you prepare this section and not drop it completely out.
§ Sharepoint is a server product. Though it’s hot you can still exclude the same. But if your job description is saying sharepoint you need to prepare this section as well.
§ WPF. This section can be omitted, if you are pure web developer, you would be hardly concerned with WPF. But if you are applying for job description which is doing windows development then WPF is a must.
Senior level categories
For senior’s, questions around design patterns, UML and project management will be asked more. They will probed around management capabilities, writing technical documents, architecture etc.
Others
Other than technical capabilities, people also question around:-
§   What’s your role?
§   What’s your architecture of your current project?
§   Why you are leaving your current organization?
§   What’s your salary expectation?
Exhaustive list of c# interview question covering 16 important c# section
Section 1:    Top 50 technical and Non-technical questions
Can you explain architecture of your current project?
What role did you play in your project and company?
What’s your salary expectation?
Why do you want to leave your previous organization?
How much do you rate yourself between 1 to 10?
Can you speak about yourself?
How can we improve performance of .NET?
What is the difference between .NET 1.X,2.0,3.0, 3.5 and 4.0?
What is ILcode,JIT,CLR, CTS, CLS and CAS?
What is a garbage collector?
What is GAC?
What are stack,heap,value, reference types, boxing and unboxing?
How are exceptions handled in .NET?
What are different types of collections in .NET?
What are generics ?
Explain Abstraction,encapsulation, inheritance and polymorphism?
How is abstract class different from aninterface?
What are the different types of polymorphism?
How does delegate differ from an event?
What are different access modifiers?
Can you explain connection, command, datareader and dataset  in ADO.NET ?
How does “Dataset” differ from a “Data Reader”?
How is ASP.NET page life cycle executed?
What are Httphandlers and HttpModules and difference between them?
What are different kind of validator controls in ASP.NET ?
How is ‘Server.Transfer’ different from ‘response.Redirect’ ?
Can you explain windows, forms and passport authentication?
What is difference between Grid view, Data list, and repeater?
Which are the various modes of storing ASP.NET session?
How can we do caching in ASP.NET?
What is ViewState?
What are indexes and what is the difference between clustered and non-clustered?
How is stored procedure different from functions?
What’s the difference between web services and remoting?
What’s the difference between WCF and Web services?
What are end point, contract, address, and bindings?
What is WPF and silverlight?
What is LINQ and Entity framework?
What’s the difference between LINQ to SQL and Entity framework?
What are design patterns?
Which design patterns are you familiar with?
Can you explain singleton pattern?
What is MVC, MVP and MVVM pattern?
What is UML and which are the important diagrams?
What are different phases in a software life cycle?
What is Ajax?
How did you do unit testing in your project?
What is Agile?
How did you do code reviews?
How did you convert requirements to technical document?
Section 2:    Basic .NET Framework
What is an IL code?
Why IL code is not fully compiled?
Who compiles the IL code and how does it work?
How does JIT compilationwork?
What are different types of JIT?
What is Native Image Generator (Ngen.exe)?
So does it mean that NGEN.EXE will always improve performance?
What is a CLR?
What is the difference betweenmanaged and unmanaged code?
What is a garbage collector?
What are generations in Garbage collector (Gen 0, 1 and 2)?
Garbage collector cleans managed code,how do we clean unmanaged code?
But when we create a destructor the performance falls down?
So how can we clean unmanaged objects and also maintain performance?
Can we force garbage collector to run?
What is difference between finalize and dispose?
What is CTS?
What is a CLS (Common Language Specification)?
What is an Assembly?
What are the different types of Assembly?
What is Namespace?
What is Difference between NameSpace and Assembly?
What is ILDASM?
What is Manifest?
Where is the version information stored of an assembly?
Is versioning applicable to private assemblies?
What is the use of strong names?
What is Delay signing?
What is GAC?
How to add and remove an assembly from GAC?
If we have two versions of the same assembly in GAC how to we make a choice?
What is reflection?
What are stack and heap?
What are Value types and Reference types?
What is concept of Boxing and Unboxing?
How performance is affected due to boxing and unboxing?
How can we avoid boxing and unboxing?
How to prevent my .NET DLL to be decompiled?
What is the difference between Convert.toString and .toString () method?
How can we handle exceptions in .NET?
How can I know from which source the exception occurred?
What if we do not catch the exception?
What are system level exceptions and application level exceptions?
Can two catch blocks be executed?
What are different types of collections in .NET?
What is the difference between arraylist and list?
Are Arraylist faster or Arrays?
What are hashtable collections?
What are Queues and stack collection?
Can you explain generics in .NET?
Can you explain the concept of generic collection?
What is the difference between dictionary and hashtable?
What are the generic equivalent for array list,stack, queues and hashtable?
What is the use of IEnumerable, ICollection, Ilist and IDictionary?
What is code access security (CAS)?
So how does CAS actually work?
Is CAS supported in .NET 4.0?
What is sandboxing?
How can we create a windows service using .NET?
What is serialization and deserialization in .NET?
Can you mention some scenarios where we can use serialization?
When should we use binary serialization as compared to XML serialization?
Can you explain the concept of “Short Circuiting”?
What is the difference between “Typeof” and “GetType” ?
Will the following c# code compile?
Section 3:   OOPS
What is Object Oriented Programming?
What is a Class and object?
What are different properties provided by Object-oriented systems?
How can we implement encapsulation in .NET?
What’s the difference between abstraction and encapsulation?
How is inheritance implemented in .NET?
What are the two different types of polymorphism?
How can we implement static polymorphism?
How can we implement dynamic polymorphism?
What is the difference overriding and overloading?
What is operator overloading?
What are abstract classes?
What are abstract methods?
What is an Interface?
Do interface have accessibility modifier.
Can we create an object of abstract class or an interface?
What is difference between abstract classes and interfaces?
An abstract with only abstract method, how is it different from interfaces?
If we want to update interface with new methods, what is the best practice?
What is a delegate?
How can we create a delegate?
What is a multicast delegate?
What are Events?
What is the difference between delegate and events?
Do events have return type?
Can events have access modifiers?
Can we have shared events?
What is shadowing?
What is the difference between Shadowing and Overriding?
If we inherit a class do the private variables also get inherited?
How can we stop the class from further inheriting?
What is the use of “Must inherit” keyword in VB.NET?
What are similarities between Class and structure?
What is the difference between Class and structure’s?
What does virtual keyword mean?
What are shared (VB.NET)/Static(C#) variables?
What is ENUM?
What is nested Classes?
If you create the child class object which constructor will fire first?
In what instances you will declare a constructor to be private?
Can we have different access modifiers on get/set methods of a property?
If we put goto / return statement in try / catch block will the finally code execute?
What is Indexer?
Can we have static indexer in C#?
Section 4:    ADO.NET
What are the different components in ADO.NET?
What is the namespace in which .NET has the data functionality class?
When should we use System.Data.SqlClient and System.Data.OleDB ?
What is difference between dataset and data reader?
What is the use of command objects?
What are Dataset objects?
What is the use of data adapter?
What are basic methods of Data adapter?
How can we fire a simple SQL Statement using ADO ?
How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
How can we force the connection object to close after my data reader is closed?
I want to force the data reader to return only schema of the data store rather than data.
How can we fine-tune the command object when we are expecting a single row?
Which is the best place to store connection string in .NET projects?
How do you fill the dataset?
What are the various methods provided by the dataset object to generate XML?
How can we save all data from dataset?
How can we check that some changes have been made to dataset since it was loaded?
How can we add/remove row is in “Data Table” object of “Dataset”?
What is basic use of “Data View”?
What is the difference between “Dataset” and “Data Reader”?
How can we load multiple tables in a Dataset?
How can we add relation between tables in a Dataset?
What is the use of Command Builder?
What’s difference between “Optimistic” and “Pessimistic” locking?
How many ways are there to implement optimistic locking in ADO.NET?
How can do pessimistic locking?
How can we perform transactions in .NET?
What is difference between Dataset.Clone and Dataset.Copy?
Can you explain the difference between an ADO.NET Dataset and an ADO Record set?
Explain in detail the fundamental of connection pooling?
What is Maximum Pool Size in ADO.NET Connection String?
How to enable and disable connection pooling?
What are  the major differences between classic ADO and ADO.NET?
Section 5:    ASP.NET
Can you explain ASP.NET page life cycle?
What are Httphandlers and HttpModules?
What is the difference between Httphandlers and HttpModules?
How do we write a Httphandler ?
How do we write anHttpModule?
Can you explain how ASP.NET application life cycle works?
In which event are the controls fully loaded?
How can we identify that the Page is Post Back?
What is the use of @ Register directives?
What is the use of Smart Navigation property?
What is AppSetting Section in “Web.Config” file?
Where is View State information stored?
How can we create custom controls in ASP.NET?
How many types of validation controls are provided by ASP.NET?
How can we force all the validation control to run?
How can we check if all the validation control are valid and proper?
If client side validation is enabled, will server side code still run ?
Which JavaScript file is referenced for validating the validators at the client side?
How to disable client side script in validators?
How can I show the entire validation error message in a message box on the client side?
If a validation is  very complex what will you do ?
Can you explain “AutoPostBack”?
How can you enable automatic paging in Data Grid?
What is the use of “GLOBAL.ASAX” file?
What is the difference between “Web.config” and “Machine.Config”?
What is a SESSION and APPLICATION object?
What is the difference between ‘Server.Transfer’ and ‘response.Redirect’ ?
What is the difference between Authentication and authorization?
What is impersonation in ASP.NET?
What are the various ways of authentication techniques in ASP.NET?
Can you explain Forms authentication in detail?
How do I sign out in forms authentication?
If cookies are disabled how will forms authentication work?
How do we implement windows authentication?
How can we do single sign on in ASP.NET?
Can you explain membership and role providers in ASP.Net 2.0?
Can you explain master pages concept in ASP.NET?
So how do you create master pages?
What is the concept of Web parts?
What are partial classes in ASP.NET ?
What is the difference between data grid and grid view?
What is difference between Grid view, Data list, and repeater?
From performance point of view, how do they rate?
What is the method to customize columns in Data Grid?
How can we format data inside Data Grid?
How to decide on the design consideration to take a Data grid, data list, or repeater?
What are major events in GLOBAL.ASAX file?
How can we kill a user session?
How do you upload a file in ASP.NET?
How do I send email message from ASP.NET?
What are different IIS isolation levels?
ASP used STA threading model, what is the threading model used for ASP.NET.
What is the use of <%@ page aspcompat=true %> attribute?
Explain the differences between Server-side and Client-side code?
How to use a checkbox in a data grid?
What is the difference between “Web farms” and “Web garden”?
How do we configure “Web Garden”?
What’s the difference between trace and debug in ASP.NET?
How do you enable tracing in on an ASP.NET page?
Which namespace is needed to implement debug and trace ?
Can you explain the concept of trace listener?
What aretrace switches?
What is an application object?
What is the use of cache object?
What is the difference between Cache object and application object?
How can get access to cache object?
What are dependencies in cache and types of dependencies?
Can you show a simple code showing file dependency in cache?
What is Cache Callback in Cache?
What is scavenging?
What are different types of caching using cache object of ASP.NET?
How can you cache different version of same page using ASP.NET cache object?
How will implement Page Fragment Caching?
Can you compare ASP.NET sessions with classic ASP?
Which are the various modes of storing ASP.NET session?
Do session use cookies?
Is Session_End event supported in all session modes?
Where do you specify session state mode in ASP.NET?
What are the other ways you can maintain state?
What are benefits and Limitation of using Hidden fields?
What is ViewState?
How do we ensure viewstate is not tampered?
Does the performance for viewstate vary according to User controls?
What are benefits and Limitation of using Viewstate for state management?
How can you use Hidden frames to cache client data ?
What are benefits and limitations of using Hidden frames?
What are benefits and limitations of using Cookies?
What is Query String and what are benefits and limitations of using Query Strings?
What is Absolute and Sliding expiration?
What is cross page posting?
How do we access viewstate value of the current page in the next page ?
Can we post and access view state in another ASP.NET page?
What is SQL Cache Dependency in ASP.NET 2.0?
How do we enable SQL Cache Dependency in ASP.NET 2.0?
What is Post Cache substitution?
Why do we need methods to be static for Post Cache substitution?
How do we encrypt web.config files in ASP.NET 2.0 ?
In .NET 1.X how was the encryption implemented for config files?
How do you send a email using ASP.NET ?
How did you deployment and setup in ASP.NET ?
Section 6:   MVC (Model view controller)
What is MVC?
Can you explain the complete flow of MVC?
Is MVC suitable for both windows and web application?
What are the benefits of using MVC?
Is MVC different from a 3 layered architecture?
What is the latest version of MVC?
What is the difference between each version of MVC?
What are routing in MVC?
Where is the route mapping code written?
Can we map multiple URL’s to the same action?
How can we navigate from one view to other view using hyperlink?
How can we restrict MVC actions to be invoked only by GET or POST?
How can we maintain session in MVC?
What is the difference between tempdata ,viewdata and viewbag?
What are partial views in MVC?
How did you create partial view and consume the same?
How can we do validations in MVC?
Can we display all errors in one go?
What are the other data annotation attributes for validation in MVC?
How can we enable data annotation validation on client side?
What is razor in MVC?
Why razor when we already had ASPX?
So which is a better fit Razor or ASPX?
How can you do authentication and authorization in MVC?
How to implement windows authentication for MVC?
How do you implement forms authentication in MVC?
How to implement Ajax in MVC?
What kind of events can be tracked in AJAX ?
Figure 6.9:- tracked in AJAX
What is the difference between “ActionResult” and “ViewResult”?
What are the different types of results in MVC?
What are “ActionFilters”in MVC?
Can we create our custom view engine using MVC?
Figure 6.12:- output  How to send result back in JSON format in MVC?
Figure 6.13:- JSON format in MVC   What is “WebAPI”?
But WCF SOAP also does the same thing, so how does “WebAPI” differ?
With WCF also you can implement REST,So why “WebAPI”?
How to implement “WebAPI” in MVC?
Section 7:   SQL SERVER
What is normalization? What are different types of normalization?
What is denormalization?
What are the different types of joins? What is the difference between them?
What is a candidate key?
What are indexes and what is the difference between clustered and nonclustered?
How can you increase SQL performance?
What is DTS?
What is fill factor ?
What is RAID and how does it work?
What is the difference between DELETE and TRUNCATE TABLE?
If locking is not implemented, what issues can occur?
What are different transaction levels in SQL SERVER?
What are the different locks in SQL SERVER?
Can we suggest locking hints to SQL SERVER?
What is LOCK escalation?
What are the different ways of moving data between databases in SQL Server?
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
What is the difference between UNION and UNION ALL SQL syntax?
How can you raise custom errors from stored procedure?
What is ACID fundamental?
What is DBCC?
What is the purpose of Replication?
What are the different types of replication supported by SQL SERVER?
What is BCP utility in SQL SERVER?
What are the different types of triggers in SQl SERVER?
If we have multiple AFTER Triggers , can we specify sequence ?
What is SQL injection?
What is the difference between Stored Procedure and User Defined Function?
Section 7: Remoting, Web services and WCF
What is the Web services ,remoting and WCF ?
What is an application domain?
What is .NET Remoting?
Which class does the remote object has to inherit?
What are two different types of remote object creation mode in .NET remoting?
What are the basic steps to implement remoting?
What are drawbacks of remoting and how can we overcome the same?
What is a Web Service?
What’s the difference between web services and remoting?
What is UDDI?
What is DISCO?
What is WSDL?
What are the steps to create a web service and consume it?
How do we secure a web service?
Does web service have state?
What is SOA?
What’s the difference between WCF and Web services?
What are end point, contract, address, and bindings?
What are the main components of WCF?
What is a service contract, operation contract and Data Contract?
What are the various ways of hosting a WCF service?
How do we host a WCF service in IIS?
What are the advantages of hosting WCF Services in IIS as compared to self-hosting?
What are different bindings supported by WCF?
What is the difference between BasicHttpBinding and WsHttpBinding ?
Can we overload WCF service methods and functions?
What is a one-way operation?
In one way contract we do not get call back, how can we solve the same?
How can we host a service on two different protocols on a single server?
How can we integrate with WCF services with MSMQ?
How can we do security in WCF services?
In what scenarios will you use message security and transport security?
Where do we specify security option in WCF services?
What are the different ways of doing WCF concurrency?
What are different ways of doing WCF instancing?
What is REST?
How can we make WCF rest enabled?
Can we call two WCF services in one transaction?
How can we enable debugging and tracing on WCF services?
How are exceptions thrown in WCF?
What is the difference between WCF fault exceptions and .NET exceptions?
Section 8: WPF and Silverlight
What is WPF?
What is the need of WPF when we had windowsforms?
How does hardware acceleration work with WPF?
Does that mean WPF has replaced DirectX?
So can we define WPF in a precise way?
What is XAML?
So is XAML meant only for WPF ?
Can you explain the overall architecture of WPF?
Which are the different namespaces and classes in WPF ?
What is App.xaml in WPF project?
What are dependency properties?
Are XAML file compiled or built on runtime?
Can you explain how we can separate code and XAML?
How can we access XAML objects in behind code?
What is SilverLight?
Can SilverLight run in other platforms other than window?
Come on, even WPF runs under browser why SilverLight ?
Can SilverLight run in other platforms other than window?
What is the relationship between Silver Light, WPF and XAML?
What is XAP file in Silverlight?
Can you explain Sliver Light architecture?
What are the various basic steps to make a simple Silver Light application?
What are the different kinds of bindings in Silverlight?
How does Silverlight connect with databases?
What are the 2 important points we noted when we call WCF service from Silverlight?
What are the different ways of doing alignment in Silverlight and WPF?
What is expression blend?
Section 9: LINQand Entity framework
Define LINQ?
How does LINQ help us from the perspective of business objects?
Can you explain how a basic LINQ Query looks like?
How do we write a LINQ query to search with criteria?
How can do a join using LINQ query?
How can we do a group by using LINQ query?
What are entity classes in LINQ?
How can we load the LINQ entity  class ?
How do we define 1 to many and many to 1 relationship in LINQ?
How can we call a stored procedure using LINQ ?
How can we insert, update and delete using LINQ?
What are DBML files in LINQ?
What is Entity framework?
What’s the difference between LINQ to SQL and Entity framework?
What are CSDL, SSDL and MSL?
What is the work of EDMX file?
How can we browse using entity framework classes?
How can we add using EF?
How can we use stored procedures in entity frame work?
What are POCO classes in Entity framework?
Section 10:    Design patterns,UML, Estimation and Project management
What are design patterns?
Which design patterns have you used in your project?
Can you explain singleton pattern?
Can you explain Façade pattern?
What is MVC, MVP and MVVM pattern?
What is MVC pattern?
How can we implement MVC in ASP.NET?
What is MVP?
What is MVVM?
What is the difference between MVC, MVP and MVVM and when to use what?
What is three-tier architecture?
Have you ever worked with Microsoft Application Blocks, if yes then which?
What is Service Oriented architecture?
What are different ways you can pass data between tiers?
What is UML?
How many types of diagrams are there in UML?
What are advantages of using UML?
How did you implement UML in your project?
What are different phases in a software life cycle?
Can you explain different software development life cycles?
What does Agile mean?
What is SCRUM?
What does product owner, product back log and sprint mean in SCRUM?
Can you explain how SCRUM flows?
Can you explain different roles in SCRUM?
When should we choose Agile and when should we choose waterfall?
What are some of the important metrics in project?
What is effort variance?
What is CAR (Causal Analysis and Resolution)?
What is DAR (Decision Analysis and Resolution)?
What is a fish bone diagram?
What is Pareto principle?
How do you handle change request?
What is internal change request?
What is difference between SITP and UTP in testing?
Which software have you used for project management?
People in your project do not perform, what will you do?
What is black box testing and White box testing?
What is the difference between Unit testing, Assembly testing and Regression testing?
What is V model in testing?
How do you start a project?
How did you do resource allocations?
How will you do code reviews?
What is CMMI?
What are the five levels in CMMI?
What is SIX sigma?
What are DMAIC and DMADV?
What are the various ways of doing software estimation ?
What is function point estimation?
How did you estimate by using function points ?
What is the FP per day in your current company?
What is SMC approach of estimation?
How do you estimate maintenance project and change requests?
Section 11:     Ajax
What problem does Ajax solve?
What is Ajax?
What is the fundamental behind Ajax?
How do we use XMLHttpRequest object in JavaScript?
Can you explain Scriptmanager control in Ajax?
What is the use of update panel inAjax?
How do we consume web service in Ajax?
Can you explain the concept of triggers in ‘UpdatePanel’ control?
Can you explain the ‘UpdateProgress’ component?
How can you do validations in Ajax?
How do we do exception handling in Ajax?
What is JSON?
Do all technologies support JSON?
Section 12:  Reports
How do we access crystal reports in .NET?
What are the various components in crystal reports?
What basic steps are needed to display a simple report in crystal?
Can crystal reports be published as a web service?
How do we invoke the crystal report web service?
How do we add formulas using crystal reports?
How do we pass parameters to crystal reports?
How do we export from crystal reports?
How do we print to printer using crystal?
How do we generate cross tab reports?
How can we do grouping in crystal?
Can you explain three-pass reporting which crystal report uses?
Can you explain reporting services architecture?
We have two IIS application ‘Reports’ and ‘Reportserver’ what do they do ?
Can you explain Report definition language (RDL) file in reporting services?
What is the basic process of making a report in reporting services?
How can we consume reports in ASP.NET?
Can you explain the difference between private and shared data sources?
How does reports caching in reporting services work ?
What are the major differences between Crystal and SQL reporting services?
Section 13:     Threading
What is Multi-tasking?
What is Multi-threading?
What is a Thread?
Did VB6 support multi-threading?
Can we have multiple threads in one App domain?
Which namespace has threading?
Can you explain in brief how can we implement threading?
How can we change priority and what the levels of priority are provided by .NET?
What does Address Of operator do in background?
How can you reference current thread of the method?
what is Thread.Sleep () in threading?
How can we make a thread sleep for infinite period?
What is Suspend and Resume in Threading?
What the way to stop a long running thread?
How do I debug thread?
What is Thread.Join () in threading?
What are Daemon threads and how can a thread be created as Daemon?
How is shared data managed in threading?
Can we use events with threading?
How can we know a state of a thread?
What is use of Interlocked class ?
What is a monitor object?
What are wait handles?
What isManualResetEvent and AutoResetEvent?
What is Reader Writer Locks?
How can you avoid deadlock in threading?
What is the difference between thread and process?
Section 14:    XML
What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What is the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type Definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is XSL?
What is element and attributes in XML?
Which are the namespaces in .NET used for XML?
What are the standard ways of parsing XML document?
In What scenarios will you use a DOM parser and SAX parser?
How was XML handled during COM times?
What is the main difference between MSML and .NET Framework XML classes?
What are the core functionalities in XML .NET framework? Can you explain in detail those functionalities?
What is XSLT?
Define XPATH?
What is the concept of XPOINTER?
What is an XMLReader Class?
What is XMLTextReader?
How do we access attributes using “XmlReader”?
Explain simple Walk through of XmlReader?
What does XmlValidatingReader class do?
Section 15:    NET Interoperability
How can we use COM Components in .NET?
We have developed the COM wrapper do we have to still register the COM?
How can we use .NET components in COM?
How can we make Windows API calls in .NET?
When we use windows API in .NET is it managed or unmanaged code?
What is COM?
What is Reference counting in COM?
Can you describe IUKNOWN interface in short?
Can you explain what DCOM is?
How do we create DCOM object in VB6?
How to implement DTC in .NET?
How many types of Transactions are there in COM + .NET?
How do you do object pooling in .NET?
What are types of compatibility in VB6?
What is equivalent for regsvr32 exe in .NET?
Section 16:      Windows workflow Foundation
What is Windows Workflow Foundation?
What is a Workflow?
What are different types of Workflow in Windows Workflow foundation?
when should we use a sequential workflow and when should we use state machines?
How do we create workflows using designer?
How do we specify conditions in Work flow?
How do you handle exceptions in workflow?
What is the use of XOML files?
How can we pass parameters to workflow?   

Thursday, November 1, 2007

Interview Questions

Basic .NET and ASP.NET interview questionsExplain the .NET architecture. How many languages .NET is supporting now? - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported. (Check in Page -12)
How is .NET able to support multiple languages? - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
How ASP .NET different from ASP? - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
Resource Files: How to use the resource files, how to know which language to use?What is smart navigation? - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
What is view state? - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single controlExplain the life cycle of an ASP .NET page.
How do you validate the controls in an ASP .NET page? - Using special validation controls that are meant for this. We have Range Validator, Email Validator.Can the validation be done in the server side? Or this can be done only in the Client side? - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
How to manage pagination in a page? - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.
Interview Questions - C#What’s the implicit name of the parameter that gets passed into the class’ set method?Value, and its datatype depends on whatever variable we’re changing.How do you inherit from a class in C#? Place a colon and then the name of the base class. Notice that it’s double colon in C++.
Does C# support multiple inheritance? No, use interfaces instead.When you inherit a protected class-level variable, who is it available to? Classes in the same namespace.
Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.Describe the accessibility modifier protected internal. It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one.
How many constructors should I write? Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.
What’s the top .NET class that everything is derived from? System.Object.
How’s method overriding different from overloading? When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.What does the keyword virtual mean in the method definition? The method can be over-ridden.Can you declare the override method static while the original method is non-static? No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.
Can you override private virtual methods? No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.Can you prevent your class from being inherited and becoming a base class for some other classes? Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.
Can you allow class to be inherited, but prevent the method from being over-ridden? Yes, just leave the class public and make the method sealed.What’s an abstract class? A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.
When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)? When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.What’s an interface class? It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.
Why can’t you specify the accessibility modifier for methods inside the interface? They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.Can you inherit multiple interfaces? Yes, why not.And if they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
What’s the difference between an interface and abstract class? In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
How can you overload a method? Different parameter data types, different number of parameters, different order of parameters.
If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
What’s the difference between System.String and System.StringBuilder classes? System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
Can you store multiple data types in System.Array? No.
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.
How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.
What’s class SortedList underneath? A sorted HashTable.
Will finally block get executed if the exception had not occurred? Yes.
What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.
What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.
What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
What namespaces are necessary to create a localized application? System.Globalization, System.Resources.What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch.
What’s the difference between and XML documentation tag? Single line code example and multiple-line code example.Is XML case-sensitive? Yes, so and are different elements.What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.
What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.
How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.
What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed.
What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).
What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications.What does the parameter Initial Catalog define inside Connection String? The database name to connect to.
What’s the data provider name to connect to Access database? Microsoft.Access.
What does Dispose method do with the connection object? Deletes it from the memory.What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.
General Questions1. Does C# support multiple-inheritance? No.
2. Who is a protected class-level variable available to? It is available to any sub-class (a class inheriting this class).
3. Are private class-level variables inherited? Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
4. Describe the accessibility modifier “protected internal”. It is available to classes that are within the same assembly and derived from the specified base class.
5. What’s the top .NET class that everything is derived from? System.Object.
6. What does the term immutable mean?The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
7. What’s the difference between System.String and System.Text.StringBuilder classes?
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
8. What’s the advantage of using System.Text.StringBuilder over System.String?StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.9. Can you store multiple data types in System.Array?No.
10. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
11. How can you sort the elements of the array in descending order?By calling Sort() and then Reverse() methods.
12. What’s the .NET collection class that allows an element to be accessed using a unique key?HashTable.
13. What class is underneath the SortedList class?A sorted HashTable.
14. Will the finally block get executed if an exception has not occurred?­Yes.15. What’s the C# syntax to catch any possible exception?A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
16. Can multiple catch blocks be executed for a single try statement?No. Once the proper catch block processed, control is transferred to the finally block (if there are any).
17. Explain the three services model commonly know as a three-tier application.Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
Class Questions1. What is the syntax to inherit from a class in C#? Place a colon and then the name of the base class.Example: class MyNewClass : MyBaseClass
2. Can you prevent your class from being inherited by another class? Yes. The keyword “sealed” will prevent the class from being inherited.
3. Can you allow a class to be inherited, but prevent the method from being over-ridden?Yes. Just leave the class public and make the method sealed.
4. What’s an abstract class?A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.
5. When do you absolutely have to declare a class as abstract?1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract.
6. What is an interface class?Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.
7. Why can’t you specify the accessibility modifier for methods inside the interface?They all must be public, and are therefore public by default.
8. Can you inherit multiple interfaces?Yes. .NET does support multiple interfaces.
9. What happens if you inherit multiple interfaces and they have conflicting method names?It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. To Do: Investigate
10. What’s the difference between an interface and abstract class?In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.
11. What is the difference between a Struct and a Class?Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.
Method and Property Questions1. What’s the implicit name of the parameter that gets passed into the set method/property of a class? Value. The data type of the value parameter is defined by whatever data type the property is declared as.
2. What does the keyword “virtual” declare for a method or property? The method or property can be overridden.
3. How is method overriding different from method overloading? When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.
4. Can you declare an override method to be static if the original method is not static? No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)
5. What are the different ways a method can be overloaded? Different parameter data types, different number of parameters, different order of parameters.
6. If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.