ADO.NET 2.0 Interview Preparation Guide
Download PDF
Add New Question

ADO.NET 2.0 Frequently Asked Questions in various ADO.NET 2.0 Interviews asked by the interviewer. So learn ADO.NET 2.0 with the help of this ADO.NET 2.0 Interview questions and answers guide and feel free to comment as your suggestions, questions and answers on any ADO.NET 2.0 Interview Question or answer by the comment feature available on the page.

14 ADO.NET 2.0 Questions and Answers:

1 :: Explain How to create dynamic Gridview?

Many times we have the requirement where we have to create columns dynamically. This article describes you about the dynamic loading of data using the Data Table as the data source. Details of the Grid Let?s have a look at the code to understand better. Create a gridview in the page, Drag and drop the GridView on to the page Or Manually type GridView definition in the page. public partial class _Default : System.Web.UI.Page { #region constants const string NAME = "NAME"; const string ID = "ID"; #endregion protected void Page_Load(object sender, EventArgs e) { loadDynamicGrid(); } private void loadDynamicGrid() { #region Code for preparing the DataTable //Create an instance of DataTable DataTable dt = new DataTable(); //Create an ID column for adding to the Datatable DataColumn dcol = new DataColumn(ID ,typeof(System.Int32)); dcol.AutoIncrement = true; dt.Columns.Add(dcol); //Create an ID column for adding to the Datatable dcol = new DataColumn(NAME, typeof(System.String)); dt.Columns.Add(dcol); //Now add data for dynamic columns //As the first column is auto-increment, we do not have to add any thing. //Let's add some data to the second column. for (int nIndex = 0; nIndex < 10; nIndex++) { //Create a new row DataRow drow = dt.NewRow(); //Initialize the row data. drow[NAME] = "Row-" + Convert.ToString((nIndex + 1)); //Add the row to the datatable. dt.Rows.Add(drow); } #endregion //Iterate through the columns of the datatable to set the data bound field dynamically. foreach (DataColumn col in dt.Columns) { //Declare the bound field and allocate memory for the bound field. BoundField bfield = new BoundField(); //Initalize the DataField value. bfield.DataField = col.ColumnName; //Initialize the HeaderText field value. bfield.HeaderText = col.ColumnName; //Add the newly created bound field to the GridView. GrdDynamic.Columns.Add(bfield); } //Initialize the DataSource GrdDynamic.DataSource = dt; //Bind the datatable with the GridView. GrdDynamic.DataBind(); } }
Post Your Answer

2 :: Explain Which name space is used to get assembly details?

System.Assembly is the name space which u need to include in u r program to get the assembly details.To get the assembly details of the current running one is thru reflection so u need another namespace called System.Reflection "Happy Programming"
Post Your Answer

3 :: Explain How to pass multiple tables in datasets simultaneously?

sqldataadopter .fill(Ds,"tableName")
again create new sql dataadopetr and fill this ds with sceond name of table giving..
Post Your Answer

4 :: Explain the difference in an Abstract Class and an Interface?

An Abstract class has abstract methods. An Abtsract class can not be instanitiated directly. All the abtract methods are implemented in the derived class. There is no multiple inheritance here.

Interface class also has abstract methods and all of them are public. You can have multiple inheritance with Interfaces.

Feature Interface Abstract class
Multiple inheritance A class may inherit several interfaces. A class may inherit only one abstract class.
Default implementation An interface cannot provide any code, just the signature. An abstract class can provide complete, default code and/or just the details that have to be overridden.
Access Modfiers An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public An abstract class can contain access modifiers for the subs, functions, properties
Core VS Peripheral Interfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface. An abstract class defines the core identity of a class and there it is used for objects of the same type.
Homogeneity If various implementations only share method signatures then it is better to use Interfaces. If various implementations are of the same kind and use common behaviour or status then abstract class is better to use.
Speed Requires more time to find the actual method in the corresponding classes. Fast
Adding functionality (Versioning) If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method. If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.
Fields and Constants No fields can be defined in interfaces An abstract class can have fields and constrants defined
Post Your Answer

5 :: Explain How to bind the controls(best practice) comboboxes to the data in the dataset?

DropDownList1.DataTextField = "FieldName";
DropDownList1.DataValueField = "FieldName";
Post Your Answer

6 :: How to identify the controls which can be used for binding data?

Control which drives from BaseDataBoundControl Class

Serves as the base class for controls that bind to data using an ASP.NET data source control.
Post Your Answer

7 :: Explain the Differences between OLEDB SQL SERVER, OLEDBDOTNET PROVIDER?

OleDBDotNet Provider can be used to connect to any DataSource but OleDb SQL SERVER can be used to connect only to a SQL Server DataSource.
Post Your Answer

8 :: Explain the difference in Record set and Dataset?

Data Reader worked as conventional Record Set of VB but Data Set Can store a complete database with all the relations and constraints.

Data Reader worked in Read only where as Data Set provide u the flexibility of Updating data also.

Data Reader worked in connected mode only, whereas Data set works in disconnected mode also.

Recordset is a collection of records returned by the query.

Dataset is merely a collection of tables.
Post Your Answer

9 :: Explain all the classes those are used for database connections between sql server and

1.SqlClientPermission - Enables the .NET Framework Data Provider for SQL Server to help ensure that a user has a security level adequate to access a data source.

2.SqlClientPermissionAttribute - Associates a security action with a custom security attribute.

3. SqlCommand - Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database. This class cannot be inherited.

4.SqlCommandBuilder - Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated SQL Server database. This class cannot be inherited.

5. SqlConnection - Represents an open connection to a SQL Server database. This class cannot be inherited.

6.SqlDataAdapter - Represents a set of data commands and a database connection that are used to fill the DataSet and update a SQL Server database. This class cannot be inherited.

7.SqlDataReader - Provides a means of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited.

8.SqlError - Collects information relevant to a warning or error returned by SQL Server. This class cannot be inherited.

9.SqlErrorCollection - Collects all errors generated by the .NET Framework Data Provider for SQL Server. This class cannot be inherited.

10.SqlException - The exception that is thrown when SQL Server returns a warning or error. This class cannot be inherited.

11.SqlInfoMessageEventArgs - Provides data for the InfoMessage event. This class cannot be inherited.

12.SqlParameter - Represents a parameter to a SqlCommand, and optionally, its mapping to DataSet columns. This class cannot be inherited.

13.SqlParameterCollection - Represents a collection of parameters relevant to a SqlCommand as well as their respective mappings to columns in a DataSet. This class cannot be inherited.

14.SqlRowUpdatedEventArgs - Provides data for the RowUpdated event. This class cannot be inherited.

15.SqlRowUpdatingEventArgs- Provides data for the RowUpdating event. This class cannot be inherited.

16. SqlTransaction - Represents a Transact-SQL transaction to be made in a SQL Server database. This class cannot be inherited.
Post Your Answer

10 :: What is difference between ado and

ADO and ADO.NET are different in several ways:

ADO works with connected data. This means that when you access data, such as viewing and updating data, it is real-time, with a connection being used all the time. This is barring, of course, you programming special routines to pull all your data into temporary tables.

ADO.NET uses data in a disconnected fashion. When you access data, ADO.NET makes a copy of the data using XML. ADO.NET only holds the connection open long enough to either pull down the data or to make any requested updates. This makes ADO.NET efficient to use for Web applications. It's also decent for desktop applications.

ADO has one main object that is used to reference data, called the Recordset object. This object basically gives you a single table view of your data, although you can join tables to create a new set of records. With ADO.NET, you have various objects that allow you to access data in various ways. The DataSet object will actually allow you to store the relational model of your database. This allows you to pull up customers and their orders, accessing/updating the data in each related table individually.

ADO allows you to create client-side cursors only, whereas ADO.NET gives you the choice of either using client-side or server-side cursors. In ADO.NET, classes actually handle the work of cursors. This allows the developer to decide which is best. For Internet development, this is crucial in creating efficient applications.

Whereas ADO allows you to persist records in XML format, ADO.NET allows you to manipulate your data using XML as the primary means. This is nice when you are working with other business applications and also helps when you are working with firewalls because data is passed as HTML and XML.
Post Your Answer
Add New Question