Welcome to mahenrathi.com: Journey into the Heart

  Technical/Interview Questions on ADO.Net, Web Services, Remoting  Home

Please share with me if you have more on this subject. Errors and ommisions are expected so please ingore if you find any.

(ADO.NET)


Advantage of ADO.Net?
  • ADO.NET Does Not Depend On Continuously Live Connections
  • Database Interactions Are Performed Using Data Commands
  • Data Can Be Cached in Datasets
  • Datasets Are Independent of Data Sources
  • Data Is Persisted as XML
  • Schemas Define Data Structures

How would u connect to database using .NET?
SqlConnection nwindConn = new SqlConnection("Data Source=localhost; Integrated Security=SSPI;" +
                                            "Initial Catalog=northwind");
nwindConn.Open();

What are relation objects in dataset and how & where to use them?
In a DataSet that contains multiple DataTable objects, you can use DataRelation objects to relate one table to another, to navigate through the tables, and to return child or parent rows from a related table.  Adding a DataRelation to a DataSet adds, by default, a UniqueConstraint to the parent table and a ForeignKeyConstraint to the child table.
The following code example creates a DataRelation using two DataTable objects in a DataSet. Each DataTable contains a column named CustID, which serves as a link between the two DataTable objects. The example adds a single DataRelation to the Relations collection of the DataSet. The first argument in the example specifies the name of the DataRelation being created. The second argument sets the parent DataColumn and the third argument sets the child DataColumn.
custDS.Relations.Add("CustOrders",
custDS.Tables["Customers"].Columns["CustID"],
custDS.Tables["Orders"].Columns["CustID"]);

OR

private void CreateRelation()
{
// Get the DataColumn objects from two DataTable objects in a DataSet.
DataColumn parentCol;
DataColumn childCol;
// Code to get the DataSet not shown here.
parentCol = DataSet1.Tables["Customers"].Columns["CustID"];
childCol = DataSet1.Tables["Orders"].Columns["CustID"];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders", parentCol, childCol);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);
}

Difference between OLEDB Provider and SqlClient ?
Ans: SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer. It's faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.
What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?
  • System.Data.OleDb – classes that make up the .NET Framework Data Provider for OLE DB-compatible data sources. These classes allow you to connect to an OLE DB data source, execute commands against the source, and read the results.
    • System.Data.SqlClient – classes that make up the .NET Framework Data Provider for SQL Server, which allows you to connect to SQL Server 7.0, execute commands, and read results. The System.Data.SqlClient namespace is similar to the System.Data.OleDb namespace, but is optimized for access to SQL Server 7.0 and later.
    • System.Data.Odbc - classes that make up the .NET Framework Data Provider for ODBC. These classes allow you to access ODBC data source in the managed space.
    • System.Data.OracleClient - classes that make up the .NET Framework Data Provider for Oracle. These classes allow you to access an Oracle data source in the managed space.

    Difference between DataReader and DataAdapter / DataSet and DataAdapter?
      You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Using the DataReader can increase application performance and reduce system overhead because only one row at a time is ever in memory.
      After creating an instance of the Command object, you create a DataReader by calling Command.ExecuteReader to retrieve rows from a data source, as shown in the following example.
      SqlDataReader myReader = myCommand.ExecuteReader();
      You use the Read method of the DataReader object to obtain a row from the results of the query.
      while (myReader.Read())
        Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
      myReader.Close();
      The DataSet is a memory-resident representation of data that provides a consistent relational programming model regardless of the data source. It can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet represents a complete set of data including related tables, constraints, and relationships among the tables. The methods and objects in a DataSet are consistent with those in the relational database model. The DataSet can also persist and reload its contents as XML and its schema as XML Schema definition language (XSD) schema.
      The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet. If you are connecting to a Microsoft SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand and SqlConnection. For other OLE DB-supported databases, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects.

    Which method do you invoke on the DataAdapter control to load your generated dataset with data?
    Fill()
    Explain different methods and Properties of DataReader which you have used in your project?
    Read
    GetString
    GetInt32
    while (myReader.Read())
      Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
    myReader.Close();

    What happens when we issue Dataset.ReadXml command?
    Reads XML schema and data into the DataSet.
    In how many ways we can retrieve table records count? How to find the count of records in a dataset?
    foreach(DataTable thisTable in myDataSet.Tables){
    // For each row, print the values of each column.
    foreach(DataRow myRow in thisTable.Rows){

    How to check if a datareader is closed or opened?
    IsClosed()
    What happens when u try to update data in a dataset in .NET while the record is already deleted in SQL SERVER as backend? (OR)
    What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)

    How do you merge 2 datasets into the third dataset in a simple manner? OR If you are executing these statements in commandObject. "Select * from Table1;Select * from Table2” how you will deal result set?

    How do you sort a dataset?

    If a dataset contains 100 rows, how to fetch rows between 5 and 15 only?

    Differences between dataset.clone and dataset.copy?
    Clone - Copies the structure of the DataSet, including all DataTable schemas, relations, and constraints. Does not copy any data.
    Copy - Copies both the structure and data for this DataSet.
    What is the use of parameter object?

    How to generate XML from a dataset and vice versa?

    What is method to get XML and schema from Dataset?
    ans: getXML () and get Schema ()
    How do u implement locking concept for dataset?

    (WEB SERVICES)

    What is a WebService and what is the underlying protocol used in it?Why Web Services?
    Web Services are applications delivered as a service on the Web. Web services allow for programmatic access of business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.
    There are three main uses of Web services.
  • Application integration Web services within an intranet are commonly used to integrate business applications running on disparate platforms. For example, a .NET client running on Windows 2000 can easily invoke a Java Web service running on a mainframe or Unix machine to retrieve data from a legacy application.
  • Business integration Web services allow trading partners to engage in e-business leveraging the existing Internet infrastructure. Organizations can send electronic purchase orders to suppliers and receive electronic invoices. Doing e-business with Web services means a low barrier to entry because Web services can be added to existing applications running on any platform without changing legacy code.
  • Commercial Web services focus on selling content and business services to clients over the Internet similar to familiar Web pages. Unlike Web pages, commercial Web services target applications not humans as their direct users. Continental Airlines exposes flight schedules and status Web services for travel Web sites and agencies to use in their applications. Like Web pages, commercial Web services are valuable only if they expose a valuable service or content. It would be very difficult to get customers to pay you for using a Web service that creates business charts with the customers? data. Customers would rather buy a charting component (e.g. COM or .NET component) and install it on the same machine as their application. On the other hand, it makes sense to sell real-time weather information or stock quotes as a Web service. Technology can help you add value to your services and explore new markets, but ultimately customers pay for contents and/or business services, not for technology

  • Are Web Services a replacement for other distributed computing platforms?
    No. Web Services is just a new way of looking at existing implementation platforms.
    In a Webservice, need to display 10 rows from a table. So DataReader or DataSet is best choice?
    A: WebService will support only DataSet.
    How to generate WebService proxy? What is SOAP, WSDL, UDDI and the concept behind Web Services? What are various components of WSDL? What is the use of WSDL.exe utility?
    SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet, for example using request and reply messages or sending entire documents. SOAP is simple, easy to use, and completely neutral with respect to operating system, programming language, or distributed computing platform.
    After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise), a better way was needed to describe the messages and how they are exchanged. The Web Services Description Language (WSDL) is a particular form of an XML Schema, developed by Microsoft and IBM for the purpose of defining the XML message, operation, and protocol mapping of a web service accessed using SOAP or other XML protocol. WSDL defines web services in terms of "endpoints" that operate on XML messages. The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly, so they can be mapped to multiple physical implementations. The current WSDL spec describes how to map messages and operations to SOAP 1.1, HTTP GET/POST, and MIME. WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages. The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using "ports").
    The Universal Description, Discovery, and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information, including the web services a business exposes to the Internet. UDDI is an independent consortium of vendors, founded by Microsoft, IBM, and Ariba, for the purpose of developing an Internet standard for web service description registration and discovery. Microsoft, IBM, and Ariba also are hosting the initial deployment of a UDDI service, which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses). UDDI uses a private agreement profile of SOAP (i.e. UDDI doesn't use the SOAP serialization format because it's not well suited to passing complete XML documents (it's aimed at RPC style interactions). The main idea is that businesses use the SOAP APIs to register themselves with UDDI, and other businesses search UDDI when they want to discover a trading partner, for example someone from whom they wish to procure sheet metal, bolts, or transistors. The information in UDDI is categorized according to industry type and geographical location, allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact. Once a specific business is chosen, another call to UDDI is made to obtain the specific contact information for that business. The contact information includes a pointer to the target business's WSDL or other XML schema file describing the web service that the target business publishes.
    How to generate proxy class other than .net app and wsdl tool?
    To access an XML Web service from a client application, you first add a Web reference, which is a reference to an XML Web service. When you create a Web reference, Visual Studio creates an XML Web service proxy class automatically and adds it to your project. This proxy class exposes the methods of the XML Web service and handles the marshalling of appropriate arguments back and forth between the XML Web service and your application. Visual Studio uses the Web Services Description Language (WSDL) to create the proxy.
    To generate an XML Web service proxy class:
    • From a command prompt, use Wsdl.exe to create a proxy class, specifying (at a minimum) the URL to an XML Web service or a service description, or the path to a saved service description.
      Wsdl /language:language  /protocol:protocol /namespace:myNameSpace /out:filename
      /username:username /password:password /domain:domain <url or path>

    What is a proxy in web service? How do I use a proxy server when invoking a Web service?
     

    asynchronous web service means?
    What are the events fired when web service called?
    How will do transaction in Web Services?
    How does SOAP transport happen and what is the role of HTTP in it? How you can access a webservice using soap?
    What are the different formatters can be used in both? Why?.. binary/soap
    How you will protect / secure a web service?
    For the most part, things that you do to secure a Web site can be used to secure a Web Service. If you need to encrypt the data exchange, you use Secure Sockets Layer (SSL) or a Virtual Private Network to keep the bits secure. For authentication, use HTTP Basic or Digest authentication with Microsoft® Windows® integration to figure out who the caller is.
    these items cannot:
  • Parse a SOAP request for valid values
    • Authenticate access at the Web Method level (they can authenticate at the Web Service level)
    • Stop reading a request as soon as it is recognized as invalid
    1. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcontransactionsupportinaspnetwebservices.asp

    How will you expose/publish a webservice?
    What is disco file?
    What’s the attribute for webservice method? What is the namespace for creating webservice?
    [WebMethod]
    using System.Web;
    using System.Web.Services;


    (REMOTING)

    What is Remoting?
    The process of communication between different operating system processes, regardless of whether they are on the same computer. The .NET remoting system is an architecture designed to simplify communication between objects living in different application domains, whether on the same computer or not, and between different contexts, whether in the same application domain or not.
    Difference between web services & remoting?
    1.  
    ASP.NET Web Services .NET Remoting
    Protocol Can be accessed only over HTTP Can be accessed over any protocol (including TCP, HTTP, SMTP and so on)
    State Management Web services work in a stateless environment Provide support for both stateful and stateless environments through Singleton and SingleCall objects
    Type System Web services support only the datatypes defined in the XSD type system, limiting the number of objects that can be serialized. Using binary communication, .NET Remoting can provide support for rich type system
    Interoperability Web services support interoperability across platforms, and are ideal for heterogeneous environments. .NET remoting requires the client be built using .NET, enforcing homogenous environment.
    Reliability Highly reliable due to the fact that Web services are always hosted in IIS Can also take advantage of IIS for fault isolation. If IIS is not used, application needs to provide plumbing for ensuring the reliability of the application.
    Extensibility Provides extensibility by allowing us to intercept the SOAP messages during the serialization and deserialization stages. Very extensible by allowing us to customize the different components of the .NET remoting framework.
    Ease-of-Programming Easy-to-create and deploy. Complex to program.

    Though both the .NET Remoting infrastructure and ASP.NET Web services can enable cross-process communication, each is designed to benefit a different target audience. ASP.NET Web services provide a simple programming model and a wide reach. .NET Remoting provides a more complex programming model and has a much narrower reach.
    As explained before, the clear performance advantage provided by TCPChannel-remoting should make you think about using this channel whenever you can afford to do so. If you can create direct TCP connections from your clients to your server and if you need to support only the .NET platform, you should go for this channel. If you are going to go cross-platform or you have the requirement of supporting SOAP via HTTP, you should definitely go for ASP.NET Web services.
    Both the .NET remoting and ASP.NET Web services are powerful technologies that provide a suitable framework for developing distributed applications. It is important to understand how both technologies work and then choose the one that is right for your application. For applications that require interoperability and must function over public networks, Web services are probably the best bet. For those that require communications with other .NET components and where performance is a key priority, .NET Remoting is the best choice. In short, use Web services when you need to send and receive data from different computing platforms, use .NET Remoting when sending and receiving data between .NET applications. In some architectural scenarios, you might also be able to use.NET Remoting in conjunction with ASP.NET Web services and take advantage of the best of both worlds.
    The Key difference between ASP.NET webservices and .NET Remoting is how they serialize data into messages and the format they choose for metadata.  ASP.NET uses XML serializer for serializing or Marshalling. And XSD is used for Metadata.  .NET Remoting relies on
    System.Runtime.Serialization.Formatter.Binary and System.Runtime.Serialization.SOAPFormatter and relies on .NET CLR Runtime assemblies for metadata.


    Can you pass SOAP messages through remoting?
    CAO and SAO.
    Client Activated objects are those remote objects whose Lifetime is directly Controlled by the client. This is in direct contrast to SAO. Where the server, not the client has complete control over the lifetime of the objects.
    Client activated objects are instantiated on the server as soon as the client request the object to be created. Unlike as SAO a CAO doesn’t delay the object creation until the first method is called on the object. (In SAO the object is instantiated when the client calls the method on the object)
    singleton and singlecall.
    Singleton types never have more than one instance at any one time. If an instance exists, all client requests are serviced by that instance.
    Single Call types always have one instance per client request. The next method invocation will be serviced by a different server instance, even if the previous instance has not yet been recycled by the system.
    What is Asynchronous Web Services?
    Web Client class and its methods?
    Flow of remoting?
    What is the use of trace utility?
    Using the SOAP Trace Utility
    The Microsoft® Simple Object Access Protocol (SOAP) Toolkit 2.0 includes a TCP/IP trace utility, MSSOAPT.EXE. You use this trace utility to view the SOAP messages sent by HTTP between a SOAP client and a service on the server.
  • Using the Trace Utility on the Server
    To see all of a service's messages received from and sent to all clients, perform the following steps on the server.
  • On the server, open the Web Services Description Language (WSDL) file.
  • In the WSDL file, locate the <soap:address> element that corresponds to the service and change the location attribute for this element to port 8080. For example, if the location attribute specifies <http://MyServer/VDir/Service.wsdl> change this attribute to <http://MyServer:8080/VDir/Service.wsdl>.
  • Run MSSOAPT.exe.
  • On the File menu, point to New, and either click Formatted Trace (if you don't want to see HTTP headers) or click Unformatted Trace (if you do want to see HTTP headers).
  • In the Trace Setup dialog box, click OK to accept the default values.
  • Using the Trace Utility on the Client
    To see all messages sent to and received from a service, do the following steps on the client.
  • Copy the WSDL file from the server to the client.
  • Modify location attribute of the <soap:address> element in the local copy of the WSDL document to direct the client to localhost:8080 and make a note of the current host and port. For example, if the WSDL contains <http://MyServer/VDir/Service.wsdl>, change it to <http://localhost:8080/VDir/Service.wsdl> and make note of "MyServer".
  • On the client, run MSSOPT.exe.
  • On the File menu, point to New, and either click Formatted Trace (if you don't want to see HTTP headers) or click Unformatted Trace (if you do want to see HTTP headers).
  • In the Destination host box, enter the host specified in Step 2.
  • In the Destination port box, enter the port specified in Step 2.
  •  Click OK.
  •   Top

    Other Channels

    My Guestbook




     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Go back to Home !

     


    © RCW (India)
    For Queries, comments and feedback 
    Click here