Testing FAQs 1

1).What is ‘Software Quality Assurance’?

Software QA involves the entire software development PROCESS – monitoring and improving the process, making sure that any agreed-upon standards and procedures are followed, and ensuring that problems are found and dealt with. It is oriented to ‘prevention’.

2).What is ‘Software Testing’?

Testing involves operation of a system or application under controlled conditions and evaluating the results (eg, ‘if the user is in interface A of the application while using hardware B, and does C, then D should happen’). The controlled conditions should include both normal and abnormal conditions. Testing should intentionally attempt to make things go wrong to determine if things happen when they shouldn’t or things don’t happen when they should. It is oriented to ‘detection’. 

  • Organizations vary considerably in how they assign responsibility for QA and testing. Sometimes they’re the combined responsibility of one group or individual. Also common are project teams that include a mix of testers and developers who work closely together, with overall QA processes monitored by project managers. It will depend on what best fits an organization’s size and business structure.

3).What are some recent major computer system failures caused by software bugs?

  • In March of 2002 it was reported that software bugs in Britain’s national tax system resulted in more than 100,000 erroneous tax overcharges. The problem was partly attibuted to the difficulty of testing the integration of multiple systems.
  • A newspaper columnist reported in July 2001 that a serious flaw was found in off-the-shelf software that had long been used in systems for tracking certain U.S. nuclear materials. The same software had been recently donated to another country to be used in tracking their own nuclear materials, and it was not until scientists in that country discovered the problem, and shared the information, that U.S. officials became aware of the problems.
  • According to newspaper stories in mid-2001, a major systems development contractor was fired and sued over problems with a large retirement plan management system. According to the reports, the client claimed that system deliveries were late, the software had excessive defects, and it caused other systems to crash.
  • In January of 2001 newspapers reported that a major European railroad was hit by the aftereffects of the Y2K bug. The company found that many of their newer trains would not run due to their inability to recognize the date ’31/12/2000′; the trains were started by altering the control system’s date settings.
  • News reports in September of 2000 told of a software vendor settling a lawsuit with a large mortgage lender; the vendor had reportedly delivered an online mortgage processing system that did not meet specifications, was delivered late, and didn’t work.
  • In early 2000, major problems were reported with a new computer system in a large suburban U.S. public school district with 100,000+ students; problems included 10,000 erroneous report cards and students left stranded by failed class registration systems; the district’s CIO was fired. The school district decided to reinstate it’s original 25-year old system for at least a year until the bugs were worked out of the new system by the software vendors.
  • In October of 1999 the $125 million NASA Mars Climate Orbiter spacecraft was believed to be lost in space due to a simple data conversion error. It was determined that spacecraft software used certain data in English units that should have been in metric units. Among other tasks, the orbiter was to serve as a communications relay for the Mars Polar Lander mission, which failed for unknown reasons in December 1999. Several investigating panels were convened to determine the process failures that allowed the error to go undetected.
  • Bugs in software supporting a large commercial high-speed data network affected 70,000 business customers over a period of 8 days in August of 1999. Among those affected was the electronic trading system of the largest U.S. futures exchange, which was shut down for most of a week as a result of the outages.
  • In April of 1999 a software bug caused the failure of a $1.2 billion military satellite launch, the costliest unmanned accident in the history of Cape Canaveral launches. The failure was the latest in a string of launch failures, triggering a complete military and industry review of U.S. space launch programs, including software integration and testing processes. Congressional oversight hearings were requested.
  • A small town in Illinois received an unusually large monthly electric bill of $7 million in March of 1999. This was about 700 times larger than its normal bill. It turned out to be due to bugs in new software that had been purchased by the local power company to deal with Y2K software issues.
  • In early 1999 a major computer game company recalled all copies of a popular new product due to software problems. The company made a public apology for releasing a product before it was ready.
  • The computer system of a major online U.S. stock trading service failed during trading hours several times over a period of days in February of 1999 according to nationwide news reports. The problem was reportedly due to bugs in a software upgrade intended to speed online trade confirmations.
  • In April of 1998 a major U.S. data communications network failed for 24 hours, crippling a large part of some U.S. credit card transaction authorization systems as well as other large U.S. bank, retail, and government data systems. The cause was eventually traced to a software bug.
  • January 1998 news reports told of software problems at a major U.S. telecommunications company that resulted in no charges for long distance calls for a month for 400,000 customers. The problem went undetected until customers called up with questions about their bills.
  • In November of 1997 the stock of a major health industry company dropped 60% due to reports of failures in computer billing systems, problems with a large database conversion, and inadequate software testing. It was reported that more than $100,000,000 in receivables had to be written off and that multi-million dollar fines were levied on the company by government agencies.
  • A retail store chain filed suit in August of 1997 against a transaction processing system vendor (not a credit card company) due to the software’s inability to handle credit cards with year 2000 expiration dates.
  • In August of 1997 one of the leading consumer credit reporting companies reportedly shut down their new public web site after less than two days of operation due to software problems. The new site allowed web site visitors instant access, for a small fee, to their personal credit reports. However, a number of initial users ended up viewing each others’ reports instead of their own, resulting in irate customers and nationwide publicity. The problem was attributed to "…unexpectedly high demand from consumers and faulty software that routed the files to the wrong computers."
  • In November of 1996, newspapers reported that software bugs caused the 411 telephone information system of one of the U.S. RBOC’s to fail for most of a day. Most of the 2000 operators had to search through phone books instead of using their 13,000,000-listing database. The bugs were introduced by new software modifications and the problem software had been installed on both the production and backup systems. A spokesman for the software vendor reportedly stated that ‘It had nothing to do with the integrity of the software. It was human error.’
  • On June 4 1996 the first flight of the European Space Agency’s new Ariane 5 rocket failed shortly after launching, resulting in an estimated uninsured loss of a half billion dollars. It was reportedly due to the lack of exception handling of a floating-point error in a conversion from a 64-bit integer to a 16-bit signed integer.
  • Software bugs caused the bank accounts of 823 customers of a major U.S. bank to be credited with $924,844,208.32 each in May of 1996, according to newspaper reports. The American Bankers Association claimed it was the largest such error in banking history. A bank spokesman said the programming errors were corrected and all funds were recovered.
  • Software bugs in a Soviet early-warning monitoring system nearly brought on nuclear war in 1983, according to news reports in early 1999. The software was supposed to filter out false missile detections caused by Soviet satellites picking up sunlight reflections off cloud-tops, but failed to do so. Disaster was averted when a Soviet commander, based on a what he said was a ‘…funny feeling in my gut’, decided the apparent missile attack was a false alarm. The filtering software code was rewritten.

4).Why is it often hard for management to get serious about quality assurance?

Solving problems is a high-visibility process; preventing problems is low-visibility. This is illustrated by an old parable:

In ancient China there was a family of healers, one of whom was known throughout the land and employed as a physician to a great lord. The physician was asked which of his family was the most skillful healer. He replied,  "I tend to the sick and dying with drastic and dramatic treatments, and on occasion someone is cured and my name gets out among the lords." "My elder brother cures sickness when it just begins to take root, and his skills are known among the local peasants and neighbors."
"My eldest brother is able to sense the spirit of sickness and eradicate it before it takes form. His name is unknown outside our home."

5).Why does software have bugs?

  • miscommunication or no communication – as to specifics of what an application should or shouldn’t do (the application’s requirements).
  • software complexity – the complexity of current software applications can be difficult to comprehend for anyone without experience in modern-day software development. Windows-type interfaces, client-server and distributed applications, data communications, enormous relational databases, and sheer size of applications have all contributed to the exponential growth in software/system complexity. And the use of object-oriented techniques can complicate instead of simplify a project unless it is well-engineered.
  • programming errors – programmers, like anyone else, can make mistakes.
  • changing requirements – the customer may not understand the effects of changes, or may understand and request them anyway – redesign, rescheduling of engineers, effects on other projects, work already completed that may have to be redone or thrown out, hardware requirements that may be affected, etc. If there are many minor changes or any major changes, known and unknown dependencies among parts of the project are likely to interact and cause problems, and the complexity of keeping track of changes may result in errors. Enthusiasm of engineering staff may be affected. In some fast-changing business environments, continuously modified requirements may be a fact of life. In this case, management must understand the resulting risks, and QA and test engineers must adapt and plan for continuous extensive testing to keep the inevitable bugs from running out of control – see ‘What can be done if requirements are changing continuously?’ in Part 2 of the FAQ.
  • time pressures – scheduling of software projects is difficult at best, often requiring a lot of guesswork. When deadlines loom and the crunch comes, mistakes will be made.
  • egos – people prefer to say things like:

·                  ‘no problem’ ·                  ‘piece of cake’·                  ‘I can whip that out in a few hours’·                  ‘it should be easy to update that old code’·                 ·                 instead of:·                  ‘that adds a lot of complexity and we could end up·                     making a lot of mistakes’·                  ‘we have no idea if we can do that; we’ll wing it’·                  ‘I can’t estimate how long it will take, until I·                     take a close look at it’·                  ‘we can’t figure out what that old spaghetti code·                     did in the first place’·                 ·                 If there are too many unrealistic ‘no problem’s’, the·                 result is bugs.·                 

  • poorly documented code – it’s tough to maintain and modify code that is badly written or poorly documented; the result is bugs. In many organizations management provides no incentive for programmers to document their code or write clear, understandable code. In fact, it’s usually the opposite: they get points mostly for quickly turning out code, and there’s job security if nobody else can understand it (‘if it was hard to write, it should be hard to read’).
  • software development tools – visual tools, class libraries, compilers, scripting tools, etc. often introduce their own bugs or are poorly documented, resulting in added bugs.

6).How can new Software QA processes be introduced in an existing organization?

  • A lot depends on the size of the organization and the risks involved. For large organizations with high-risk (in terms of lives or property) projects, serious management buy-in is required and a formalized QA process is necessary.
  • Where the risk is lower, management and organizational buy-in and QA implementation may be a slower, step-at-a-time process. QA processes should be balanced with productivity so as to keep bureaucracy from getting out of hand.
  • For small groups or projects, a more ad-hoc process may be appropriate, depending on the type of customers and projects. A lot will depend on team leads or managers, feedback to developers, and ensuring adequate communications among customers, managers, developers, and testers.
  • In all cases the most value for effort will be in requirements management processes, with a goal of clear, complete, testable requirement specifications or expectations.

7).What is verification? validation?

Verification typically involves reviews and meetings to evaluate documents, plans, code, requirements, and specifications. This can be done with checklists, issues lists, walkthroughs, and inspection meetings. Validation typically involves actual testing and takes place after verifications are completed. The term ‘IV & V’ refers to Independent Verification and Validation.

8).What is a ‘walkthrough’?

A ‘walkthrough’ is an informal meeting for evaluation or informational purposes. Little or no preparation is usually required.

9).What’s an ‘inspection’?

An inspection is more formalized than a ‘walkthrough’, typically with 3-8 people including a moderator, reader, and a recorder to take notes. The subject of the inspection is typically a document such as a requirements spec or a test plan, and the purpose is to find problems and see what’s missing, not to fix anything. Attendees should prepare for this type of meeting by reading thru the document; most problems will be found during this preparation. The result of the inspection meeting should be a written report. Thorough preparation for inspections is difficult, painstaking work, but is one of the most cost effective methods of ensuring quality. Employees who are most skilled at inspections are like the ‘eldest brother’ in the parable in ‘Why is it often hard for management to get serious about quality assurance?’. Their skill may have low visibility but they are extremely valuable to any software development organization, since bug prevention is far more cost-effective than bug detection.

10).What kinds of testing should be considered?

  • Black box testing – not based on any knowledge of internal design or code. Tests are based on requirements and functionality.
  • White box testing – based on knowledge of the internal logic of an application’s code. Tests are based on coverage of code statements, branches, paths, conditions.
  • unit testing – the most ‘micro’ scale of testing; to test particular functions or code modules. Typically done by the programmer and not by testers, as it requires detailed knowledge of the internal program design and code. Not always easily done unless the application has a well-designed architecture with tight code; may require developing test driver modules or test harnesses.
  • incremental integration testing – continuous testing of an application as new functionality is added; requires that various aspects of an application’s functionality be independent enough to work separately before all parts of the program are completed, or that test drivers be developed as needed; done by programmers or by testers.
  • integration testing – testing of combined parts of an application to determine if they function together correctly. The ‘parts’ can be code modules, individual applications, client and server applications on a network, etc. This type of testing is especially relevant to client/server and distributed systems.
  • functional testing – black-box type testing geared to functional requirements of an application; this type of testing should be done by testers. This doesn’t mean that the programmers shouldn’t check that their code works before releasing it (which of course applies to any stage of testing.)
  • system testing – black-box type testing that is based on overall requirements specifications; covers all combined parts of a system.
  • end-to-end testing – similar to system testing; the ‘macro’ end of the test scale; involves testing of a complete application environment in a situation that mimics real-world use, such as interacting with a database, using network communications, or interacting with other hardware, applications, or systems if appropriate.
  • sanity testing – typically an initial testing effort to determine if a new software version is performing well enough to accept it for a major testing effort. For example, if the new software is crashing systems every 5 minutes, bogging down systems to a crawl, or destroying databases, the software may not be in a ‘sane’ enough condition to warrant further testing in its current state.
  • regression testing – re-testing after fixes or modifications of the software or its environment. It can be difficult to determine how much re-testing is needed, especially near the end of the development cycle. Automated testing tools can be especially useful for this type of testing.
  • acceptance testing – final testing based on specifications of the end-user or customer, or based on use by end-users/customers over some limited period of time.
  • load testing – testing an application under heavy loads, such as testing of a web site under a range of loads to determine at what point the system’s response time degrades or fails.
  • stress testing – term often used interchangeably with ‘load’ and ‘performance’ testing. Also used to describe such tests as system functional testing while under unusually heavy loads, heavy repetition of certain actions or inputs, input of large numerical values, large complex queries to a database system, etc.
  • performance testing – term often used interchangeably with ‘stress’ and ‘load’ testing. Ideally ‘performance’ testing (and any other ‘type’ of testing) is defined in requirements documentation or QA or Test Plans.
  • usability testing – testing for ‘user-friendliness’. Clearly this is subjective, and will depend on the targeted end-user or customer. User interviews, surveys, video recording of user sessions, and other techniques can be used. Programmers and testers are usually not appropriate as usability testers.
  • install/uninstall testing – testing of full, partial, or upgrade install/uninstall processes.
  • recovery testing – testing how well a system recovers from crashes, hardware failures, or other catastrophic problems.
  • security testing – testing how well the system protects against unauthorized internal or external access, willful damage, etc; may require sophisticated testing techniques.
  • compatability testing – testing how well software performs in a particular hardware/software/operating system/network/etc. environment.
  • exploratory testing – often taken to mean a creative, informal software test that is not based on formal test plans or test cases; testers may be learning the software as they test it.
  • ad-hoc testing – similar to exploratory testing, but often taken to mean that the testers have significant understanding of the software before testing it.
  • user acceptance testing – determining if software is satisfactory to an end-user or customer.
  • comparison testing – comparing software weaknesses and strengths to competing products.
  • alpha testing – testing of an application when development is nearing completion; minor design changes may still be made as a result of such testing. Typically done by end-users or others, not by programmers or testers.
  • beta testing – testing when development and testing are essentially completed and final bugs and problems need to be found before final release. Typically done by end-users or others, not by programmers or testers.
  • mutation testing – a method for determining if a set of test data or test cases is useful, by deliberately introducing various code changes (‘bugs’) and retesting with the original test data/cases to determine if the ‘bugs’ are detected. Proper implementation requires large computational resources.
Advertisements

.NET Interview Questions

1. What is the difference between ASP and ASP.Net?

New in ASP .NET
================
Better language support
Programmable controls
Event-driven programming
XML-based components
User authentication, with accounts and roles
Higher scalability
Increased performance – Compiled code
Easier configuration and deployment
Not fully ASP compatible

Language Support
================
ASP .NET uses the new ADO .NET.
ASP .NET supports full Visual Basic, not VBScript.
ASP .NET supports C# (C sharp) and C++.
ASP .NET supports JScript as before.
——————————————————————————–

ASP .NET Controls
=================
ASP .NET contains a large set of HTML controls. Almost all HTML elements on a page can be defined as ASP .NET control objects that can be controlled by scripts.
ASP .NET also contains a new set of object oriented input controls, like programmable list boxes and validation controls.
A new data grid control supports sorting, data paging, and everything you expect from a dataset control.
——————————————————————————–

Event Aware Controls
===================
All ASP .NET objects on a Web page can expose events that can be processed by ASP .NET code.
Load, Click and Change events handled by code makes coding much simpler and much better organized.

——————————————————————————–

ASP .NET Components
ASP .NET components are heavily based on XML. Like the new AD Rotator, that uses XML to store advertisement information and configuration.

——————————————————————————–

User Authentication
ASP .NET supports forms-based user authentication, including cookie management and automatic redirecting of unauthorized logins.
(You can still do your custom login page and custom user checking).
——————————————————————————–

User Accounts and Roles
ASP .NET allows for user accounts and roles, to give each user (with a given role) access to different server code and executables.
——————————————————————————–

High Scalability
Much has been done with ASP .NET to provide greater scalability.
Server to server communication has been greatly enhanced, making it possible to scale an application over several servers. One example of this is the ability to run XML parsers, XSL transformations and even resource hungry session objects on other servers.
——————————————————————————–
Compiled Code
The first request for an ASP .NET page on the server will compile the ASP .NET code and keep a cached copy in memory. The result of this is greatly increased performance.
——————————————————————————–
Easy Configuration
Configuration of ASP .NET is done with plain text files.
Configuration files can be uploaded or changed while the application is running. No need to restart the server. No more metabase or registry puzzle.
——————————————————————————–
Easy Deployment
No more server restart to deploy or replace compiled code. ASP .NET simply redirects all new requests to the new code.
——————————————————————————–

Compatibility
ASP .NET is not fully compatible with earlier versions of ASP, so most of the old ASP code will need some changes to run under ASP .NET.
To overcome this problem, ASP .NET uses a new file extension ".aspx". This will make ASP .NET applications able to run side by side with standard ASP applications on the same server
               

2. What is the difference between ADO and ADO.Net?

It takes years to explain the differences here but have a look at these 2 links. … its really good. .. it will give clear idea about them …

http://msdn.microsoft.com/msdnmag/issues/04/07/datapoints/
http://msdn.microsoft.com/msdnmag/issues/04/08/DataPoints/default.aspx

and also this PowerPoint Slides. ..which will give overview of Ado.net’s objects
http://www.microsoft.com/usa/presentations/Session1-ADO_NET.ppt

3. What is the difference between Record set and Data Set?

In brief…
A Recordset is a single resultset (ie. table)
A DataSet is a structure containing many DataTables. A DataTable is effectively the same as an ADO Recordset.

There are many additional features in a DataSet (ie. Relationships, etc.) and in a DataTable (ie. there is a command to give you the records that have been added / deleted / updated by the user) and DataViews (ie. a subset of the contents of the table – sorted/filtered).

See links below for more info:
http://www.dnjonline.com/articles/essentials/iss22_essentials.html
http://msdn.microsoft.com/msdnmag/issues/04/07/DataPoints/default.aspx

4. What is the best session state mode? What is default one?
Default one is InProc. Best Session state depends on the sistuation and the complexity of the application:

Pros and cons of the three session management solutions in brief
InProc –
stored in memory on web server
Pros: least overhead, fastest performance
Cons: breaks web clusters, restarting IIS loses sessions

StateServer – managed by a remote service (aspnet_state)
HTTP protocol over TCP port.
Pros: reasonably fast, works with clusters
Cons: clear text, no authentication, overflows…

SQLServer – stored in SQL Server DB tables
Uses normal ODBC connection.
Pros: reliable, scalable
Cons: relatively slow, much overhead 

5. What is disconnected environment?

In traditional client/server applications, components establish a connection to a database and keep it open while the application is running. For a variety of reasons, this approach is impractical in many applications:

– Open database connections take up valuable system resources. In most cases, databases can maintain only a small number of concurrent connections. The overhead of maintaining these connections detracts from overall application performance.
– Similarly, applications that require an open database connection are extremely difficult to scale up. An application that does not scale up well might perform acceptably with four users but will likely not do so with hundreds. ASP.NET Web applications in particular need to be easily scalable, because traffic to a Web site can go up by orders of magnitude in a very short period.
– In ASP.NET Web applications, the components are inherently disconnected from each other. The browser requests a page from the server; when the server has finished processing and sending the page, it has no further connection with the browser until the next request. Under these circumstances, maintaining open connections to a database is not viable, because there is no way to know whether the data consumer (the client) requires further data access.
– A model based on always-connected data can make it difficult and impractical to exchange data across application and organizational boundaries using a connected architecture. If two components need to share the same data, both have to be connected, or a way must be devised for the components to pass data back and forth.

For all these reasons, data access with ADO.NET is designed around an architecture that uses connections sparingly. Applications are connected to the database only long enough to fetch or update the data. Because the database is not holding on to connections that are largely idle, it can service many more users, This Architecture is called disconnected environment.

6. How do you get Data in to DataSet?

Source Code:

using System;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient; 

           public DataSet GetDataSet
                        (string strConnect,string[] ProcName , string[] DataTable)
            {
                        //********************************
                        //* Purpose: Returns Dataset for one or multi datatables
                        //* Input parameters:
                        //*strConnect—-Connection string
                        //*ProcName() —StoredProcedures name in array
                        //*DataTable()—DataTable name in array
                        //* Returns :
                        //*DataSet Object contains data
                        //**************************************************
              DataSet dstEorder ;
                        SqlConnection conn;
                        SqlDataAdapter dadEorder;
                        try
                        {
                                    int intCnt = ProcName.GetUpperBound(0);
                                    dstEorder = new DataSet();
                                    conn = new SqlConnection(strConnect);
                                    // if one datatable and SP
                                    if(intCnt == 0)
                                    {
                                                dadEorder = new SqlDataAdapter(ProcName[0], conn);
                                                dadEorder.Fill(dstEorder, DataTable[0]);
                                    }
                                    // more than one datatable and one SP
                                    else
                                    {
                                                conn.Open();
                                                //add first data table and first SP
                                                dadEorder = new SqlDataAdapter(ProcName[0], conn);                                        
                                                dadEorder.Fill(dstEorder, DataTable[0]);
                                                // add second datatable and second SP onwards
                                                for(int i=1 ;i< (intCnt +1) ;i++)
                                                {
                                                dadEorder.SelectCommand = new SqlCommand(ProcName[i], conn);
                                                dadEorder.Fill(dstEorder, DataTable[i]);
                                                }                                 
                                                conn.Close();
                                                }
                                                return dstEorder;
                                    }
                                    catch ( Exception objError)
                                    {
                                               //write error to the windows event log                 
                                                WriteToEventLog(objError);
                                                throw;                                      
                                    }
            }

            private void WriteToEventLog( Exception objError)
            {
                        //*************************************
                        //* Purpose:Writing error to the windows event log
                       //* Input parameters:
                        //*objError—-Exception object
                        //* Returns :                                                        
                        //*nothing
                        //* ***************************************************

                        System.Diagnostics.EventLog objEventLog = new System.Diagnostics.EventLog();
                        objEventLog.Source = "Your Application Name";
                        objEventLog.WriteEntry(objError.Message.ToString());
            }

Exmaple to Use
==============

System.Data.DataSet dst ;
string[] arrProcName = new string[2];
string[] arrTableName = new string[2];                           
arrProcName[0] = ""SP_Search  ‘" + FirstName + " ‘";
arrProcName[1] = "sp_getProduct "+ prodID;
arrTableName[0] = "Search";
arrTableName[1] = "Products";
string strConnect = "Data Source=ServerName;InitialCatalog=databaseName;UID=yourUserid; PWD=yourPassword"
dst = objdb.GetDataSet(strConn,arrProcName,arrTableName);
           

7. How do you update the DataSet?

[Visual Basic]
Public Function CreateCmdsAndUpdate(myDataSet As DataSet, myConnection As String, mySelectQuery As String, myTableName As String) As DataSet
    Dim myConn As New OleDbConnection(myConnection)
    Dim myDataAdapter As New OleDbDataAdapter()
    myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery, myConn)
    Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(MyDataAdapter)

    myConn.Open()

    Dim custDS As DataSet = New DataSet
    myDataAdapter.Fill(custDS)

    ‘ Code to modify data in DataSet here

    myDataAdapter.Update(custDS, myTableName)

    myConn.Close()

    Return custDS
End Function ‘SelectOleDbSrvRows

[C#]
public DataSet CreateCmdsAndUpdate(DataSet myDataSet,string myConnection,string mySelectQuery,string myTableName)
{
    OleDbConnection myConn = new OleDbConnection(myConnection);
    OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
    myDataAdapter.SelectCommand = new OleDbCommand(mySelectQuery, myConn);
    OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);

    myConn.Open();

    DataSet custDS = new DataSet();
    myDataAdapter.Fill(custDS);

    //code to modify data in dataset here

    myDataAdapter.Update(custDS, myTableName);

    myConn.Close();

    return custDS;
 }

8. In Multi User environment, What happens when second user updates back end, when first user already deleted / modified the same record?

The DB locks the row until the first operation is completed and

9. What is RDBMS and In-Memory Resident RDBMS?

RDBMS, short for relational database management system and pronounced as separate letters, a type of database management system (DBMS) that stores data in the form of related tables. Relational databases are powerful because they require few assumptions about how data is related or how it will be extracted from the database. As a result, the same database can be viewed in many different ways.
An important feature of relational systems is that a single database can be spread across several tables. This differs from flat-file databases, in which each database is self-contained in a single table.

Almost all full-scale database systems are RDBMS’s. Small database systems, however, use other designs that provide less flexibility in posing queries.

In-Memory Resident RDBMS is nothing but a DB with in the memory. This is what we call also as working in disconnected mode as described above. Sometimes, it is necessary to deal with the same data in multiple pages or forms inside your application. In this situation, it is always very costly to go back to the DB and get the data, so get the dat from the DB by conencting to it once and put the Data into the classes provided by MS like SqlDataAdapter,OleDbDataAdapter,DataSet,DataTable.
DataRelation and DataView

You can use these classes to build a memory-resident representation of a database (an in-memory database). A DataSet represents the in-memory database itself. Once you create a DataSet, you can populate it with one or more DataTables that represent database tables. You create the DataTables with the help of either the SqlDataAdapter or OleDbDataAdapter class. You can then define various relationships between the tables with the DataRelation class and create filtered or sorted views on the DataTables with DataViews.

Why would you want to build an in-memory database? In certain situations, it is useful to have all the data from a database table available to your ASP.NET application in such a way that it is disconnected from the underlying database. For example, using the classes from this group, you can cache one or more database tables in your server’s memory and use the same data in multiple ASP.NET pages.

10. What is 5th Normal form?

Go thru for all types of Normal Forms.
http://www.datamodel.org/NormalizationRules.html

11. What is indexing in RDBMS? Why we use and what are the types in SQL Server and what is the difference between them?

SQL Server allows two basic types of indexes:
clustered and nonclustered.

CLUSTERED

Creates an object where the physical order of rows is the same as the indexed order of the rows, and the bottom (leaf) level of the clustered index contains the actual data rows. A table or view is allowed one clustered index at a time.

NONCLUSTERED

Creates an object that specifies the logical ordering of a table. With a nonclustered index, the physical order of the rows is independent of their indexed order. The leaf level of a nonclustered index contains index rows. Each index row contains the nonclustered key value and one or more row locators that point to the row that contains the value. If the table does not have a clustered index, the row locator is the row’s disk address. If the table does have a clustered index, the row locator is the clustered index key for the row.
——————————————————————————–
The basic difference between these two depends on what you store in the Table and the way you fetches the data from the Table.

Clustered indexes are most efficient for range queries and sorts based on the clustering keys because the data pages are sorted based on the clustering keys. However, keep in mind that clusterd indexes are more expensive when it comes updates/inserts/deletes. Also, keep the clustered index keys small because all the other nonclustered indexes will use the clustring keys to locate rows in the tabels. When you don’t have a clustered index, non-clustered indexes will have row IDs in them to map directly to the table rather than using the clustered index as an intermediary to locate rows.

Whether to use composite indexes depends on whether you want to inforce primary key or unique constraints on the table based more than one column and for performance when the criteria utilize all the the columns in the composite index.

For example, if you have a composite index on columns A and B, and your queries only restrict on B, then you won’t get much performance boost. But when your queries restrict on both A and B, then you’ll get the maximum boost.

Composite indexes are also very efficient for Covered Queries. For example, if all the columns mentioned in your query (select list, where clause, join criteria, etc) are covered by one or more indexes, then SQL server can use index intersection to get the result set without touching the table proper. For example, if you have this query:

select A, B
from SomeTable
where C = 5 and D between 1 and 2

If you have two composite indexes, one on (A, B, D), and the other on C, then the above query is covered and SQL server uses index intersection to get the results very quickly without touching the table.

12. What are the objects in DataSet?
This is queations is a bit Confusing for me. What exactly is the question here?

13. How do you define the relation between tables in Data set?

DataRelation class is used to do the same.
One of the primary functions of a DataRelation is to allow navigation from one DataTable to another within a DataSet. This allows you to retrieve all the related DataRow objects in one DataTable when given a single DataRow from a related DataTable. For example, after establishing a DataRelation between a table of customers and a table of orders, you can retrieve all the order rows for a particular customer row using DataRow.GetChildRows.

The following code example creates a DataRelation between the Customers table and the Orders table of a DataSet and returns all the orders for each customer.

[Visual Basic]
Dim custOrderRel As DataRelation = custDS.Relations.Add("CustOrders", _
                     custDS.Tables("Customers").Columns("CustomerID"), _
                     custDS.Tables("Orders").Columns("CustomerID"))

Dim custRow As DataRow
Dim orderRow As DataRow

For Each custRow in custDS.Tables("Customers").Rows
  Console.WriteLine(custRow("CustomerID"))
  For Each orderRow in custRow.GetChildRows(custOrderRel)
    Console.WriteLine(orderRow("OrderID"))
  Next
Next
[C#]
DataRelation custOrderRel = custDS.Relations.Add("CustOrders",
                     custDS.Tables["Customers"].Columns["CustomerID"],
                     custDS.Tables["Orders"].Columns["CustomerID"]);
foreach (DataRow custRow in custDS.Tables["Customers"].Rows)
{
  Console.WriteLine(custRow["CustomerID"]);
  foreach (DataRow orderRow in custRow.GetChildRows(custOrderRel))
    Console.WriteLine(orderRow["OrderID"]);
}

14. Write the code to define the PK and FK relation ship using Data Set and its Objects.

Dim connstr As String
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=c:db.mdb;Mode= ReadWrite"
Dim cnn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As New DataSet()
cnn = New OleDbConnection(connstr)
da = New OleDbDataAdapter("select * from customers", cnn)
da.Fill(ds, "customers")

Here I populated the dataset with Customers table.

Primary Key Constraints
=======================
Now, we will add CustomerID as a primary key constraint to the customers table from our dataset.
Dim pk(1) As DataColumn
pk(0) = ds.Tables(0).Columns("custid")
ds.Tables("customers").PrimaryKey = pk

Foreign Key Constraints
=======================
Lets assume that we have another table called orders and I populate the orders data as follows:
Da.SelecteCommand.CommandText="select * from orders"
da.Fill(ds, "orders")

CustID is foreign key in Orders table.
Add following code that establishes foreign key constraints between them.

Dim fk As ForeignKeyConstraint
fk = New ForeignKeyConstraint("fk", ds.Tables(0).Columns("custid"),
ds.Tables(1).Columns("custid"))
fk.DeleteRule = Rule.Cascade
fk.UpdateRule = Rule.Cascade
ds.Tables(1).Constraints.Add(fk)
ds.EnforceConstraints = True

Here we have created an object of ForeignKeyConstraint with name "fk" that sets foreign key of orders table. Next, we have also set rulaes for cascade update and deletes. Finally we have added this constraint to the constraints collection of the datatable.

15. What are the scenarios for Data Reader and Data Set Usage?

A DataReader is a stream of data that is returned from a database query. When the query is executed, the first row is returned to the DataReader via the stream. The stream then remains connected to the database, poised to retrieve the next record. The DataReader reads one row at a time from the database and can only move forward, one record at a time. As the DataReader reads the rows from the database, the values of the columns in each row can be read and evaluated, but they cannot be edited.

The DataReader can only retrieve one row at a time from the data source and in order for it to get the next record, it has to maintain its connection to the data source. The DataSet, however, doesn’t need to know about where it gets its data. The DataReader can only get its data from a data source through a managed provider. The DataSet can also get its data from a data source via a managed provider, but the data source can also be loaded manually, even from an XML file on a hard drive. If the .NET Framework does not provide a managed provider that is specifically designed for your database

Your situation will dictate when and where you’ll use a DataSet versus a DataReader. For example, the DataSet’s disconnected nature allows it to be transformed into XML and sent over the wire via HTTP if appropriate. This makes it ideal as the return vehicle from business-tier objects and Web services. A DataReader cannot be serialized and thus cannot be passed between physical-tier boundaries where only string (XML) data can go.

DataSet objects are a good choice when the data must be edited or rows added or deleted from the database. It is not the only choice, however, as a DataReader could be used to retrieve the data and changes would be sent to the database via a SqlDataAdapter through a separate, self-maintained DataRow array. That process can be quite messy because the SqlDataReader cannot allow edits as the DataSet can. As mentioned earlier, the DataSet is also a good choice when you need data manipulation such as filtering, sorting, or searching. Since the DataSet can be traversed in any direction, all of these features are available. This flexibility also makes the DataSet an easy choice when the situation calls for multiple iterations of the rowset. A DataReader can move forward only, so to loop through it more than once, the DataReader would be closed and reopened and the query would hit the database a second time

16. How do u create Data Table / Data Relation objects?

See answer to Question 14.

17. What view state in ASP.Net?

Microsoft ASP.NET Web Forms pages are capable of maintaining their own state across multiple client round trips. When a property is set for a control, the ASP.NET saves the property value as part of the control’s state. To the application, this makes it appear that the page’s lifetime spans multiple client requests. This page-level state is known as the view state of the page. In Web Forms pages, their view state is sent by the server as a hidden variable in a form, as part of every response to the client, and is returned to the server by the client as part of a postback.

The view state is a key element of an ASP.NET page because it is the primary means to persist the state of the Web server controls. Whenever the page posts back, the state is restored, updated using the current form parameters, then used to run the postback event handler. Normally, the view state is a hashed string encoded as Base64 and stored in a hidden field called __VIEWSTATE. In this way, the view state is not cached on the client, but simply transported back and forth with potential issues both for security and performance. Since it is performance overhead, you need to decide properly when and where you should use viewstate in your webform

18. Write code to maintain View State.

The viewstate is enabled by default for all the server controls.

19. Can we keep Data Set in view state?
Yes.
The example stores a dataset in view state on a Web Forms page. It first creates an XML representation of the dataset and then stores the XML as a string.

Dim sw As New System.IO.StringWriter
DsNorthwind1.WriteXml(sw)
ViewState("dsNorthwind") = sw.ToString()

This example retrieves the DataSet from a view state.
if (Page.IsPostBack)
{
   System.IO.StringReader sr =
      new System.IO.StringReader((string)(ViewState["dSet"]));
   dSet.ReadXml(sr);
}

Note: As a rule, in the Web Applications, storing datasets in view state only if the dataset is very small. Large datasets can significantly increase the size of the ASPX page, resulting in slower download to the client and slower posting.

20. How to set the automatic state maintenance for controls?
By means of ViewState property for that Control. Set this property to true if you want automatic state maintennece. As I told you, The viewstate is enabled by default for all the server controls.

21. ** Does HTML controls support the automatic state maintenance?
No

22. Is view state is encrypted in between requests?
Yes, Normally, the view state is a hashed string encoded as Base64 and stored in a hidden field called __VIEWSTATE

23. What are the Record Set Lock options in ADO?

Types of Locks
adLockBatchOptimistic
Indicates optimistic batch updates. Required for batch update mode.

Many applications fetch a number of rows at once and then need to make coordinated updates that include the entire set of rows to be inserted, updated, or deleted. With batch cursors, only one round trip to the server is needed, thus improving update performance and decreasing network traffic. Using a batch cursor library, you can create a static cursor and then disconnect from the data source. At this point you can make changes to the rows and subsequently reconnect and post the changes to the data source in a batch.

adLockOptimistic
Indicates that the provider uses optimistic locking—locking records only when you call the Update method. This means that there is a chance that another user may change the data between the time you edit the record and when you call Update, which creates conflicts. Use this lock type in situations where the chances of a collision are low or where collisions can be readily resolved.

adLockPessimistic
Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately before editing. Of course, this means that the records are unavailable to other users once you begin to edit, until you release the lock by calling Update. Use this type of lock in a system where you cannot afford to have concurrent changes to data, such as in a reservation system.

adLockReadOnly
Indicates read-only records. You cannot alter the data. A read-only lock is the "fastest" type of lock because it does not require the server to maintain a lock on the records.

adLockUnspecified
Does not specify a type of lock

24. What are the Cursor types and Locations in ADO?

Static cursors
Dynamic cursors
Forward-only cursors
Keyset-driven cursors

Static cursors detect few or no changes but consume relatively few resources while scrolling, although they store the entire cursor in tempdb. Dynamic cursors detect all changes but consume more resources while scrolling, although they make the lightest use of tempdb. Keyset-driven cursors lie in between, detecting most changes but at less expense than dynamic cursors.

Although the database API cursor models consider a forward-only cursor to be a distinct type of cursor, SQL Server does not. SQL Server considers both forward-only and scroll as options that can be applied to static, keyset-driven, and dynamic cursors

25. **Does all combinations of Lock types and cursor types and locations are avaialble in ADO. What happens if we set in appropriate type?

The cursor and lock type combinations that are supported by the ADO Data Providers depend on whether the cursor is located on the client side or the server side. To view combinations for a specific location, see:

See http://support.sas.com/rnd/eai/oledb/app_cursorlocktypes.htm for more eloberated discussions.

26. When we should use location as client in ADO?

Client-side cursors, specified with the adUseClient keyword, are handled internally by ADO. These cursors offer more functionality than their server-side counterparts, and also result in less load being placed on the server. Most advanced ADO functionality is designed for use with client-side cursors, and I personally use client-side cursors for all my applications.

When using a client-side adUseClient cursor, only the adOpenStatic cursor is available, and we cannot use the adLockPessimistic lock type.

Client-side cursors also help decrease load on our SQL server, since with a static cursor data is sent to the client and then the server has no further communications with the client. This allows your server to scale a lot better than with server-side cursors.

For most uses, adUseClient/adOpenStatic is your best choice, with adLockReadOnly as your lock type for any read-only operations (export to a file, load rows to a listview, combobox, etc.) and adLockOptimistic as your lock type for any read/write operations

27. What is the difference between Optimistic and Pessimistic Locking?
Optimistic lock is an implicit lock that tries to make best assumption about locking strategy and minimize time spent in lock of resource. Optimistic lock is usually implemented with some kind of timestamp strategy. Pessimistic lock is an explicit lock that set by client.

28. What are the session Modes in ASP.Net?

Storage location

InProc – session kept as live objects in web server (aspnet_wp.exe). Use "cookieless" configuration in web.config to "munge" the sessionId onto the URL (solves cookie/domain/path RFC problems too!)
StateServer – session serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine
SQLServer – session serialized and stored in SQL server

Performance
============
InProc – Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.
StateServer – When storing data of basic types (e.g. string, integer, etc), in one test environment it’s 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you’re storing lots
of objects. You have to do performance testing for your own scenario.
SQLServer – When storing data of basic types (e.g. string, integer, etc), in one test environment it’s 25% slower than InProc. Same warning about serialization as in StateServer

HEre I would like to add more questions related to Session State of ASP.NET.

Session states works on some web servers but not on others.
A: Maybe machine name problem. See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q316112 .

Q: Why isn’t Session_End fired when I call Session_Abandon?
A: First of all, Session_End event is supported only in InProc mode. In order for Session_End to be fired, your session state has to exist first. That means you have to store some data in the session state and has completed at least one request.

Q: Why are my Session variables lost frequently when using InProc mode?
A: Probably because of application recycle. See http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316148

Q: Why does the SessionID remain the same after the Session times out or abandoned?
A:Even though the session state expires after the indicated timeout period, the session ID lasts as long as the browser session. What this implies is that the same session ID can represent multiple sessions over time where the instance of the browser remain the same.

Q: Why does the SessionID changes in every request?
A: This may happen if your application has never stored anything in the session state. In this case, a new session state (with a new ID) is created in every request, but is never saved because it contains nothing.

However, there are two exceptions to this same session ID behavior:
– If the user has used the same browser instance to request another page that uses the session state, you will get the same session ID every time. For details, see "Why does the SessionID remain the same after the Session times out?"
– If the Session_OnStart event is used, ASP.NET will save the session state even when it is empty.

Q: Can I share session state between ASP.NET and ASP pages?
A: Yes! Here is http://www.eggheadcafe.com/articles/20021207.asp on how to do this in either direction using two "intermediate" pages. And here is another article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ConvertToASPNET.asp on how to do it with SQL Server.

Q: What kinds of object can I store in session state?
A: It depends on which mode you are using:
– If you are using InProc mode, objects stored in session state are actually live objects, and so you can store whatever object you have created.
– If you are using State Server or SQL Server mode, objects in the session state will be serialized and deserialized when a request is processed. So make sure your objects are serializable and their classes must be marked as so. If not, the session state will not be saved successfully. In v1, there is a bug which makes the problem happen unnoticed. See this KB for more info:
http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;q312112

Q: How come Response.Redirect and Server.Transfer is not working in Session_End?
A: Session_End is fired internally by the server, based on an internal timer. Thus, there is no HttpRequest associted when that happens. That is why Response.Redirect or Server.Transferdoes not make sense and will not work.

Q: Do I have a valid HttpContext in Session_End?
A: No, because this event is not associated with any request.

Q: Will my session state be saved when my page hit an error?
No. Unless you call Server.ClearError in your exception handler.

Q: How do I use session state with web services?
A: The extra trick needed is on the caller side. You have to save and store the cookies used by the web service. See the MSDN documentation on HttpWebClientProtocol.CookieContainer property.

However, please note if you’re using proxy object to call a web service from your page, the web service and your page cannot share the same session state due to architecture limitation.

This can be done if you call your web service through redirect.

Q: I am writing my own HttpHandler. Why is session state not working?
A: Your HttpHandler has to implement the "marker" interface IRequiresSessionState or IReadOnlySessionState in order to use session state.

Q: I am using a webfarm, and I lost session state when directed to some web servers.
A: For session state to be maintained across different web servers in the web farm, the Application Path of the website (For example \LM\W3SVC\2) in the IIS Metabase should be identical in all the web servers in the web farm.

Q: Why isn’t session state availabe in the Application_OnAcquireRequestState (or other)
event handler?

A: Session state is available only after the HttpApplication.AcquireRequestState event is called. For details, see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhandlingpublicevents.asp

Q: If using "cookieless", how can I redirect from a HTTP page to an HTTPS page?
A: Try this:
String originalUrl = "/fxtest3/sub/foo2.aspx";
String modifiedUrl = "https://localhost" + Response.ApplyAppPathModifier(originalUrl);
Response.Redirect(modifiedUrl);
NOTE: Fully qualified URLs in the response.redirect, server.transfer, and FORM action
tags cannot be used with cookiless sessions. Here is an example of a fully qualified
URL: http://www.eggheadcafe.com/default.asp   More info here:http://www.eggheadcafe.com/articles/20021207.asp

Q: What isn’t Session available in my event handler in global.asax?
A: It depends on which event you’re handling. Session is available only after AcquireRequestState event.

Q: Does session state have a locking mechanism that serialize the access to state?
Session state implements a reader/writer locking mechanism:
– A page (or frame) that has session state write access (e.g. <%@ Page EnableSessionState="True" %>) will hold a writer lock on the session until the request finishes.
– A page (or frame) that has session state read access (e.g. <%@ Page EnableSessionState="ReadOnly" %>) will hold a reader lock on the session until the request finishes.
– Reader lock will block a writer lock; Reader lock will NOT block reader lock; Writer lock will block all reader and writer lock.
– That’s why if two frames both have session state write access, one frame has to wait for the other to finish first.

29. **Suppose session Mode is set to State server and the APP is
restarted, is the session state is available to the application?

No.

30. **While n number of users are visiting our site, If we change
the global.asa, while application is running, what happens to the
session and application variables?

31. Can an application written in COBOL language be run in .Net?

YES, Fujitsu Software came up with Fujitsu Cobol which allows the COBOL programmer to take advantage of .NET. Go thru http://www.adtools.com/info/whitepaper/net.html

32. What is CTS and CLS?

CTS is Common Type System.
The common type system defines how types are declared, used, and managed in the runtime, and is also an important part of the runtime’s support for cross-language integration. The common type system performs the following functions:

– Establishes a framework that helps enable cross-language integration, type safety, and high performance code execution.
– Provides an object-oriented model that supports the complete implementation of many programming languages.
– Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.
More at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconthecommontypesystem.asp

To fully interact with other objects regardless of the language they were implemented in, objects must expose to callers only those features that are common to all the languages they must interoperate with. For this reason, the Common Language Specification (CLS), which is a set of basic language features needed by many applications, has been defined. The CLS rules define a subset of the common type system; that is, all the rules that apply to the common type system apply to the CLS, except where stricter rules are defined in the CLS. The CLS helps enhance and ensure language interoperability by defining a set of features that developers can rely on to be available in a wide variety of languages. The CLS also establishes requirements for CLS compliance; these help you determine whether your managed code conforms to the CLS and to what extent a given tool supports the development of managed code that uses CLS features

33. What is auto event wire up property in asp.net?

Events raised by ASP.NET server controls work somewhat differently than events in traditional client forms or in client-based Web applications. The difference arises primarily because of the separation of the event itself from where the event is handled.

In client-based applications, events are raised and handled on the client. In Web Forms pages, on the other hand, events associated with server controls are raised on the client but handled on the Web server by the ASP.NET page framework.

For events raised on the client, the Web Forms control event model requires that the event information be captured on the client and an event message transmitted to the server, via an HTTP post. The page framework must interpret the post to determine what event occurred and then call the appropriate method in your code on the server to handle the event.

The ASP.NET page framework also supports an automatic way to associate page events and methods. If the AutoEventWireup attribute of the Page directive is set to true (or if it is missing, since by default it is true), the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.

The disadvantage of the AutoEventWireup attribute is that it requires that the page event handlers have specific, predictable names. This limits your flexibility in how you name your event handlers. Therefore, in Visual Studio, the AutoEventWireup attribute is set to false by default and the designer generates explicit code to bind page events to methods.

If you do set AutoEventWireup to true, Visual Studio will generate code to bind the events and the page framework will automatically call events based on their names. This can result in the same event code being called twice when the page runs

34. What is meta data?
Metadata is a description or definition of electronic data, or data about data. Often, metadata can only be accessed in certain viewing modes. Metadata can include descriptive HTML tags and information about when a document was created, and what changes have been made on that document

35. What is reflection and what’s its use?

REflection is basically a process of knowing about the properties of an assembly at run time.
The reflection reflects, the classes, interfaces, and objects in the current assembly. You’ll want to use the reflection if you are writing development tools such as debuggers, class browsers, and GUI builders.

With the reflection you can:
– Determine the class of an object.
– Get information about a class’s modifiers, fields, methods, constructors, and superclasses.
– Find out what constants and method declarations belong to an interface.
– Create an instance of a class whose name is not known until runtime.
– Get and set the value of an object’s field, even if the field name is unknown to your program until runtime.
– Invoke a method on an object, even if the method is not known until runtime.
– Create a new array, whose size and component type are not known until runtime, and then modify the array’s components

36. What is delegate? Explain? Write code?

A delegate declaration defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure

The following is a simple example of declaring and using a delegate.

// keyword_delegate.cs
// delegate declaration
delegate void MyDelegate(int i);

class Program
{
   public static void Main()
   {
      TakesADelegate(new MyDelegate(DelegateFunction));
   }

   public static void TakesADelegate(MyDelegate SomeFunction)
   {
      SomeFunction(21);
   }
  
   public static void DelegateFunction(int i)
   {
      System.Console.WriteLine("Called by delegate with number: {0}.", i);
   }
}

37. What is shadowing in vb.net?

Shadowing is a concept of polymorphism usage in Object Oriented Programming.
This is a concept related to over-riding functions at run-time or making a shadow of the object’s methods in the inherited classes.
The Shadows keyword indicates that a declared programming element shadows, or hides, an identically named element, or set of overloaded elements, in a base class. You can shadow any kind of declared element with any other kind

The purpose of shadowing is to protect the definition of your class members. The base class might undergo a change that creates an element with the same name as one you have already defined. If this happens, the Shadows keyword forces references through your class to be resolved to your previously defined member, instead of to the new base class element.

38. What is the difference between namespace and assemblies?

A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under the control of the developer. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionality related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the Microsoft® ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

 

Configure your Development Environment with the user having least privilege other than administrator.

The most common objection developers hold against using a non-admin account is that they can’t develop software with a lesser privileged account. Standard user accounts do not have the sufficient privileges to debug applications or create web applications on Microsoft Internet Information Server. To configure your development environment correctly, you’ll need a good understanding of what privileges are required to perform different tasks.

Most of the permissions needed to perform different tasks are already granted to different user groups defined on your computer.

1.       Members of the debugger users group are allowed to use Visual Studio .NET to debug processes, both locally and remotely. It is critical for all developers to have this permission, but it should not be granted to everyone because it can be exploited to gain elevated privileges.

  1. Members of the VS_Developers group can create new web applications on Microsoft Internet Information Server. Despite the name, membership in this group is not needed to do other Visual Studio .NET development, such as creating Windows Forms applications or similar.
  2. If you want to debug web applications on either Windows XP or Windows Server 2003, your user must be a granted the Log on as batch job” privilege. This privilege is already granted to the IIS_WPG group on Windows Server 2003, so if you don’t have to explicitly give users this privilege if you add them to this group. Windows XP hasn’t got an equivalent to the IIS_WPG group, so you’ll have to grant users this privilege in Windows XP environment.

Below are guides to how you can configure your Windows XP or Windows Server 2003 development environment. Both guides require Visual Studio .NET to be installed on the development computer.

Windows XP (Service Pack 2)

  1. Log on as an administrator.
  2. If you already have a regular user account you can skip to 7
  3. Open the control panel in category view and click “User Accounts”. When instructed to pick a control panel icon, click “User Accounts” again.
  4. In the “User Accounts” dialog, open the “Users” pane and click “Add…”.
  5. In the “Add New User” wizards fill in the fields in the first step and click “Next >”. On the second pane choose the “Restricted user” option and click the “Finish” button.
  6. Change to the “Advanced” tab and click the “Advanced” button in the “Advanced user management” section.
  7. In the “Local Users and Groups” dialog, locate and double-click your user in the “Users” folder.
  8. In the “User Properties” dialog, open the “Member Of” tab.The user should be a member of the “Users” group, not the “Administrators” or “Power Users” groups.
  9. Click the “Add..” button and type in “Debugger Users; VS Developers;” in the text box below “Enter the object names to select (examples):” caption.
  10. Click “OK” and close the “Local Users and Groups” dialog.
  11. Open the “Local Security Policy” console.
  12. Expand “Local Policies” and click “User Rights Assignment”
  13. Double-click “Log on as batch job”.
  14. From the “Log on as batch job Properties” dialog click the “Add User or Group…” button.
  15. In the “Add User or Group” type in name of your user account.
  16. Click “OK” and close the “Local Security Settings” console.

Windows Server 2003

  1. Log on as an administrator.
  2. Open the “Computer Management” console and expand “System Tools”.
  3. If you already have a regular user account you can skip to 7
  4. To create a new account, expand “Local Users and Groups”.
  5. Right-click “Users” and choose “New User”.
  6. In “New User” dialog fill in the required details and click “Create”.
  7. Double-click your existing or new user account in the “Computer Management” console.
  8. From the “User Properties” dialog, open the “Member Of” tab. The user should only be a member of the “Users” group, not “Administrators” or “Power Users”.
  9. Click the “Add” button and type in “Debugger Users; VS_Developers; IIS_WPG;” in the text box below “Enter the object names to select (examples):” caption.
  10. Click “OK” and close the “Computer Management” console.

 

With Regards,

UVN PardhaSaradhi

http://spaces.msn.com/members/uvnpsaradhi

 

 

What is with the combination of Response.redirect and Try catch block?

Well, most of you who have tried out the combination must have been stuck with a weird error of "Thread was being aborted" and must have wondered what has a thread got to do with Response.redirect?

Well, to answer your question here goes:-

A thread is executing your application in terms of ASP.NET worker process , when you call Response.Redirect(URL);

In your code then to redirect to the new URL specified by you ASP.NET framework must be told to stop the current execution of the page and to transfer the execution to the URL page specified in the method call.

This is done in a 2 way step :-

1)       Response.End() is called internally by Response.Redirect to stop the current execution and the ThreadAbortException is thrown.

2)       .NET framework will call catch “ThreadAbortException” and stop current execution and start executing the new page. 

Now during the Step #1 Response.End will throw out a  “ThreadAbortException” to let .NET framework know that the current execution needs to be stopped and the execution of new should begin.   

Asp.net framework catches the Redirect method’s exception, aborts the thread and use a new thread for execution of to be redirected page.

Solution :- The way to get over this problem is to specify Response.Redirect(URL,false) , this will tell .NET framework not to stop the execution of the current thread and hence the error will be resolved. 

ThreadAbortException” is a special kind of an exception even if you catch it in a catch block even then it will be raised again at the end of the catch block. When this exception is raised, the runtime executes all the finally blocks before killing the thread.

 – UVN Pardha Saradhi

Visual Studio 2005 and ASP.NET 2.0

With ASP.NET 2.0, Visual Studio 2005 has undergone some major enhancements and now provides a far superior environment for developing Web applications than previous versions. While the design environment is very familiar, the feature set has improved, making it a premier Web development tool.

Key design features for Visual Studio 2005 include the following:

  • Traditional inline coding approach, plus a new code-behind model
  • Support for all managed languages
  • Ability to edit any file anywhere (FTP, File System, Front Page Server Extensions, and so on)
  • Support for data controls, drag and drop, and database access, with a rich design surface
  • Support for visual inheritance through master pages
  • No project files, allowing projects to be manipulated outside of the tool
  • Integrated Web Site Administration Tool
  • IntelliSense included
  • Support for internationalization
  • Debugging support
  • No "build" step—ability to compile on first run

 

This feature set is really a combination of features from Visual Studio .NET and Web Matrix. As well as Visual Studio 2005 there is a stand-alone development tool targeted specifically at Web developers: Visual Web Developer Express Edition.

================

UVN Pardha Saradhi

http://spaces.msn.com/members/uvnpsaradhi/

 

Windows Services in .NET

If you want to write application that constantly monitors some files, creates a log file, or anything else which runs constantly in the background while the machine is busy doing something else, the best way to this used to be to run a windows application continuously or at a regular interval with the use of Windows scheduler. There was one big disadvantage to this — someone had to log into the system to start the application. This sort of activity has been long put behind us thanks to Windows services.

A Windows Service is a process that runs unattended and without a user interface. Windows Services are available only in Windows NT, Windows 2000, Windows XP, and Windows Server 2003. Windows Services run in their own process space and can be configured to start up during the OS boot process. Other desktop applications can interact with them, if you configure them that way.

Let’s start creating a sample Windows Service in VB.NET
=======================================================

Start by creating a Windows Service project. Select File | New Project, then select the Windows Service template and give its name as MyService.Some versions of Visual Studio .NET (VS.NET) provide a Windows Service application template that creates the skeleton of your application. Note that Visual Basic Standard Edition and Visual C# Standard Edition do not include the Windows Service application template, so you’ll have to start from scratch.
Now VS.NET creates a new project with a single VB.NET file called MyService.vb. Double-click on this file to bring up a designer view

You can set several properties for the service project. For example, you can tell Windows that this service will respond to shutdown, pause, and continue, and other events. You can also tell Windows to log service events such as stop and start in the Windows Event Log by setting the AutoLog property to True.

Now take a look at the code for the service by clicking on the "click here to switch to code view" link. The first thing you’ll notice is that the Service1 class inherits from the System.ServiceProcess.ServiceBase class. The .NET Framework’s System.ServiceProcess.ServiceBase class encapsulates essentially all of the "plumbing" required to create and control service applications. By basing your application on this class, most of the difficult work is already done for you.

This class contains the following subset of events that interact with the Windows Service Control Manager (SCM):

* OnContinue: Fires when a continue command is sent to the service by the SCM. It specifies actions to take when a service resumes normal functioning after being paused.
* OnPause: Fires when a pause command is sent to the service by the SCM. It specifies actions to take when a service pauses.
* OnPowerEvent: Fires when the computer’s power status has changed. This applies to laptop computers when they go into suspended mode, which isn’t the same as a system shutdown.
* OnShutdown: Fires when the system is shutting down. It specifies what should happen immediately prior to the system shutting down.
* OnStart: Fires when a start command is sent to the service by the SCM or when the operating system starts (for a service that starts automatically). It specifies actions to take when the service starts. An array of String objects is the event’s lone parameter.
* OnStop: Fires when a stop command is sent to the service by the SCM. It specifies actions to take when a service stops running.

The point where most of the developers are cofused is Starting a service and running a service. Note that these two are entirely different. Running a service makes it available but does not start it. Once available, a service can be started or stopped either automatically, manually, or programmatically. Depending on the setting of the ServiceBase object’s CanPauseAndContinue property, a service may also be able to pause and continue.

imports System.Diagnostics
Imports System.ServiceProcess
Public Class MyService
Inherits System.ServiceProcess.ServiceBase
Private log As EventLog
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If (disposing) Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
log.WriteEntry("Service dispose", EventLogEntryType.Information)
log.Close()
MyBase.Dispose(disposing)
End Sub
<MTAThread()> _
Shared Sub Main()
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub
Private components As System.ComponentModel.IContainer
Private Sub InitializeComponent()
components = New System.ComponentModel.Container
Me.ServiceName = "Service1"
End Sub
Protected Overrides Sub OnStart(ByVal args() As String)
log = New EventLog("Builder.com")
log.WriteEntry("Service Starting", EventLogEntryType.Information)
End Sub
Protected Overrides Sub OnStop()
log.WriteEntry("Service Stopping", EventLogEntryType.Information)
End Sub
End Class

Service Installation
====================
To install a service you must compile the service project into an exe file, and then run the utility program InstallUtil.exe (installed with the .NET Framework). At a command prompt enter the command:

   installutil servicename.exe
 

You must provide the complete path to the service’s exe file. The InstallUtil application installs the specified service. will be installed. After installing the new service, you can find it in the Services window of the Computer Management applet. (You can use the InstallUtil program to uninstall a service as well.)

Windows services are an often overlooked type of application. They are relatively specialized, but for certain type of tasks, usually in the administrative category, they fit the bill perfectly. The .NET Framework provides classes designed specifically for creating and controlling Windows service applications. Given that the required programming is relatively simple, you should take advantage of Windows services