ado.net questions and answers

Question:-How ADO.NET come into existence ?
Answer: DAO (data access model) is the first Data Access Model that is created for local databases which contains built-in Jet engine which overcome with some problem like performance and functionality issues. After this RDO (Remote Data Object) and ADO (Active Data Object) comes in market which basically designed for Client Server applications but soon ADO is more comfort then RDO. ADO a good architecture. ADO contained all the data in a recordset object which creates problems when implemented on the network where firewalls exist. Because ADO was a connected data access, which make connection open until the application is closed. This creates issue like database security and network traffic. Because open database connections use system resources to a maximum extent making the system performance less effective. This helps in developing of ADO.NET.

Question: What is Asynchronous Database Commands ? Answer:- When we execute any database. Thread that executing the command waits before the command get fully executing before executing any additional code. Thread is blocked for another process. But Asynchronous Database Commands solve this problem when database command is executing the current thread can continue on other process.Thread can execute a no of database command. There are two benefits of using Asynchronous Database Commands.1) Executing Multiple Databse Commands simultaneously improve performance.2) Because ASP.Net framework uses a limited pool service for request. Whenany request for a page is comes its assign a thread to handle the request. If framework is out of thread then job is in gueses we get error 503. But if we are using asynchronous database command then current thread is release back to current thread pool.Question:-What is Concurrency and its types?Answer: When two or more people try to update same type of data then Concurrency helps how to handle this situation there are two types of concurrencyPessimistic:-When one user try to change the data with pessimistic concurrency a lock is placed on the data so that another user cannot change that one after one another can change.
Optimistic:-In this if two user works on the same data and one change that data first then second user cannot change that same data becasue the which he have using is allready changed so he cannot do the change becasue change apply to another data that is changed by first user.

Question: How to start Outlook,NotePad file in AsP.NET with code ?
Answer: Here is the syntax to open outlook or notepad file in ASP.NET VB.NET Process.Start("Notepad.exe") Process.Start("msimn.exe"); C#.NET System.Diagnostics.Process.Start("msimn.exe"); System.Diagnostics.Process.Start("Notepad.exe");
Question: How to get result from two table in SqlDataReader ?
Answer: string str="Select * from table1;Select * from table2"; cmd.commandtext=str; dr=cmd.executereader();
Question: What is Ref Cursor in .NET and how it is link with ExecuteReader ?
Answer: Ref cursor play its role when doing with the oracle database these comes in ODP.NET. Ref Cursors are objects that link to Oracle server-side cursors.These Ref Cursor can be converted in oracle datareader with this Ref cursor we can get result with query written to pl/sql and the result can be get in .net.Now the question arise why we use Ref Cursor when we have an option of ExceuteReader reson is simple when we need more query in pl/sql means our work is done in pl/sql then we need this ref cursor for getting result set because doennot have direct connection to that table.Becasue advantage of pl/sql we can take two opertion in one query.
Question: Define tool Manage Statistics in SQL Serevr 2000 query ?
Answer: SQL Server creates internal statistics on the rows in all of our tables that is used by the Query Optimizer to select the optimal execution plan for our query. And Query Optimizer helps in doing this.Soome time when statistics isnot maintains then this is done by tool Manage Statistics.We can add,edit or delete for statistics that is maintained by SQL Server.We can experiment with different sets of statistics and see how it affects the query otimizer execution plans.
Question: Some important instruction regarding ADO.NET connection string ?
Answer: When we are making connection string always use Server's IP address not the DNS name if we use IP address it will reduce the time taken for connection to establish.Becasue server IP address is used to get a default or named instance of Sql Server that ls running. if we are running the cluster we have to use the Virtual SQL Server IP address.
Question: How to get database schema information when connection object is establish in ADO.NET ?
Answer: There is a method that helps in getting schema information that is GetSchema() and this method is called in three different ways first way when we call this method without any parameter its return the metadata(table, view, stored procedure.indexes etc).When method is called by passing metadata collection name and filter criteria returns the items from the collection after applying the filter criteria and last way is when we called by passing a metadata collection name returns information about items found in the specified collection.
Question: Which one is better WebService and Remoting ?
Answer: Both of these have little difference WebService helpfull where the user who is using WebService doesnot have the .NET plateform. On the otherside for remoting we need .Net plateform on the both side so from both of this remoting is faster then webservice.So keep in mind which of these are you using if you have .net plateform or other.

Question:-What is DataGrid wheater its a Server Control or something else ?
Answer:DataGrid is Web server control a powerful tool for displaying information from a data source. we can display editable data in a professional-looking grid by setting only a few properties. The grid has a sophisticated object model that provides you with great flexibility in how you display the data.

Question:-Define different execute methods of ADO.NET command object ?
Answer: ExecuteScalar:- This method returns a single value from the first row and first column of the result get from the execution of SQL query.
ExecuteNonQuery:- This method executes the DML SQL query just like insert, delete or update and then returns the number of rows affected by the action.
ExecuteReader:- This method returns DataReader object which is a forward-only resultset.
ExecuteXMLReader:- This method is available for SQL Server 2000 or later. Upon execution it builds XMLReader object from standard SQL query.


Question:-What DataReader class do in ADO.NET ?
Answer:To get read-only and forward only access to data we use DataReader .the DataReader object reduces the system overhead because one row at a time is taken into memory so it is quite lightweight. To get second object connection is reconnected. We can create a DataReader object by execute Execute readre() method. There are two Data Reader class one is SqlDataReader and other is OleDbDataReader.

Question:-Why is ADO.NET serialization slower than ADO ?
Answer: ADO uses binary serialization while ADO.NET uses text based serialization. Since the text takes more space, it takes longer to write it out.


Question:-Is XML is a component of ADO.NET ?
Answer: The answer of this question is always Yes because XML is an important component of ADO.NET architecture .ADO.NET use XML to store and transfer data.We not have to convert data to XML format.Datasets helps XML to integrate with ADO.NET. XML schema plays a role to get table definition,column,datatypes and constraints helps DataSet.

Question:- How to check if the Dataset has records ?
Answer:
if ds.Tables(0).Rows.Count= 0 then
'No record
else
'record found

Question:- What is the significance of CommandBehavior.CloseConnection ?
Answer: To avoid having to explicitly close the connection associated with the command used to create either a SqlDataReader or and OleDbDataReader, pass the CommandBehavior.CloseConnection argument to the ExecuteReader method of the Connection.

dr= cmd.ExecuteReader(CommandBehavior.CloseConnection);

The associated connection will be closed automatically when the Close method of the Datareader is called. This makes it all the more important to always remember to call Close on your datareaders.

Question:-Which method do you invoke on the DataAdapter control to load your generated dataset with data?
Answer: The Fill() method.

Question:-What is Dataset and Diffgram?
Answer: When sending and retrieving a DataSet from an XML Web service, the DiffGram format is implicitly used. Additionally, when loading the contents of a DataSet from XML using the ReadXml method, or when writing the contents of a DataSet in XML using the WriteXml method, you can select that the contents be read or written as a DiffGram. For more information, see Loading a DataSet from XML and Writing a DataSet as XML Data. While the DiffGram format is primarily used by the .NET Framework as a serialization format for the contents of a DataSet, you can also use DiffGrams to modify data in tables in a Microsoft SQL Server™ 2000 database.

Question:-What is typed dataset ?
Answer: A typed dataset is very much similar to a normal dataset. But the only difference is that the sehema is already present for the same. Hence any mismatch in the column will generate compile time errors rather than runtime error as in the case of normal dataset. Also accessing the column value is much easier than the normal dataset as the column definition will be available in the schema.

Question:-How can you provide an alternating color scheme in a Repeater control?
Answer: AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other row (alternating items) in the Repeater control. You can specify a different appearance for the AlternatingItemTemplate element by setting its style properties.

Question:-What are good ADO.NET object(s) to replace the ADO Recordset object?
Answer: There are alot...but the base once are SqlConnection, OleDbConnection, etc...

Question:-Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Answer:Valid answers are:
· A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
· A DataSet is designed to work without any continuing connection to the original data source.
· Data in a DataSet is bulk-loaded, rather than being loaded on demand.
· There's no concept of cursor types in a DataSet.
· DataSets have no current record pointer You can use For Each loops to move through the data.
· You can store many edits in a DataSet, and write them to the original data source in a single operation.
· Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
Question:-What are the differences between Datalist DataGrid and datarepeater ?
Answer:DataList
· Has table appearence by default
· Has no autoformat option
· has no default paging & sorting options
· can define separators between elements using template
DataGrid
· Has a grid appearence by default
· has a autoformat option
· has default paging and sorting
· has no separator between elements
DataRepeater
· simple,read-only output, has no built in support for selecting or editing items, has no DEFAULT APPEARENCE, has no default paging. 













1. Explain the .NET architecture.


2. How many languages .NET is supporting now?

When .Net was introduced it came with some 16 languages. VB.NET, C#, COBOL and PERL etc
3. How .NET is able to support multiple languages?

A language should comply the Common Language Runtime standard to become a .NET language.
In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short)
This is called as Managed Code.
This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier.
A code can call / use a function written in another language.

4. How ASP .NET different from ASP?

Scripting is separated from the HTML
Code is compiled as a DLL
So advantages of compiled
These DLLs can be ached in the server.

5. Resource Files: How to use the resource files, how to know which language to use?


6. What is smart navigation?

The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

7. What is view state?

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically.
How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET
This can be switched off / on for a single control

8. Explain the life cycle of an ASP .NET page.


9. How do you validate the controls in an ASP .NET page?

Using special validation controls that are meant for this. We have Range Validator, Email Validator,

10. Can the validation be done in the server side? Or this can be done only in the Client side?

Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.

11. How to manage pagination in a page?

Using pagination option in DataGrid control.
We have to set the number of records for a page, then it takes care of pagination by itself.

12. What is ADO .NET and what is difference between ADO and ADO.NET?

ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

0 comments:

Post a Comment