Tolal:37 Click:
1
2
ADO.net Interview Questions And Answers
Page 1
Ques: 1 Why ADO.NET?
Ans:
ADO.NET is data access layer
Ans:
We create a connection for database after that we queried the information from database.
Ans:
Data Provider is a set of components including:
1.The Connection object (SqlConnection, OleDbConnection, OdbcConnection, OracleConnection)
2.The Command object (SqlCommand, OleDbCommand, OdbcCommand, OracleCommand)
3.The DataReader object (SqlDataReader, OleDbDataReader, OdbcDataReader, OracleDataReader)
4.The DataAdapter object (SqlDataAdapter, OleDbDataAdapter, OdbcDataAdapter, OracleDataAdapter).
DataSet object represents a disconnected cache of data which is made up of DataTables and DataRelations that represent the result of the command.
Ans:
ADO stands for ActiveX Data Object .ADO.NET is an object-oriented set of libraries that allows to interact with data sources. The data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file.ADO .NET consists of classes that allow a .NET application to connect to the data source, executes commands and manage disconnected data. One of the key Differences between ADO.NET and other database technologies is how it deals with Challenge with different data sources, that means, the code you use to connect to an SQL Database will not differ that much to the one connecting to an Oracle Database.
Ques: 2 What is full name of ADO.NET?
Ans:
ActiveX Data Objects
Ques: 3 Give Short History of ADO.Net.
Ans:
Microsoft developed ActiveX Data Objects (ADO) as a COM( Component Object Model ) wrapper around OLE DB for Databases.
Ques: 4 Why ADO.NET Is a Better Data Access Layer than others?
Ques: 5 Write a sample example of ADO.Net?
Ans:
using System;
using System.Data;
using System.Data.OleDb;
// Step 1.Open Database Connection
OleDbConnection conn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\inventory\\inventory\\db\\invent.mdb;");
// Step 2.Connection database opened
conn.Open();
// Step 3.Create DataSet and Command objects
OleDbCommand cmd = new OleDbCommand(
"SELECT * FROM empr4r",
conn);
// Step 4.Execute the command
cmd.ExecuteScalar();
// Step 5.Closed this connection
conn.Close();
Ans:
using System;
using System.Data;
using System.Data.OleDb;
// Step 1.Open Database Connection
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\inventory\\inventory\\db\\invent.mdb;");
// Step 2.Connection database opened
conn.Open();
// Step 3.Create DataSet and Command objects
OleDbCommand cmd = new OleDbCommand(
"SELECT * FROM empr4r",
conn);
// Step 4.Execute the command
cmd.ExecuteScalar();
// Step 5.Closed this connection
conn.Close();
Ques: 6 Explain ADO.NET Namespaces?
Ans:
The System.Data is main namespace of ADO.Net and it has DataSet and classes (DataTable, DataColumn, DataRow, DataRelation, Constraint,etc ). System.Data has a namespace System.Data.Common.
Ques: 7 What is ADO.NET Data Structures?
Ans:
ADO.NET has three different ways of accessing database information directly which are:
1.Commands :-have classes SqlCommand and OleDbCommand , used directly to retrieve results from database queries.Command classes always support the IDbCommand interface.Commands classesare used to get a scalar result (the first column of the first row of a result set) or out parameters of a stored procedure.sort of data is retrieved using IDbCommand.ExecuteScalar() and IDbCommand.ExecuteNonQuery()
2.DataReaders has SqlDataReader and OleDbDataReader.These classes are provide something similar to ADO's Recordset using a forward-only cursor.
3.DataSets classes Microsoft uses DataReaders within the managed providers' DataAdapters to fill DataSet
Ques: 8 Define ADO.NET provides data access services in the Microsoft .NET platform?
Ans:
ADO.NET to access data by using the new .NET Framework data providers which are given below:
1.Data Provider for SQL Server (System.Data.SqlClient)
2.Data Provider for OLEDB (System.Data.OleDb)
3.Data Provider for ODBC (System.Data.Odbc).
4.Data Provider for Oracle (System.Data.OracleClient).
Ques: 9 Tell me about ADO.NET Classes?
Ans:
The ADO.NET classes are found in System.Data.dll and are integrated with the XML classes in System.Xml.dll. ADO.NET is a set of classes that expose data access services to the .NET developer. There are two central components of ADO.NET classes: the DataSet, and the .NET Framework Data Provider.
Ques: 10 Define Data Provider in ADO.NET?
Ans:
Data Provider is a set of components including:
1.The Connection object (SqlConnection, OleDbConnection, OdbcConnection, OracleConnection)
2.The Command object (SqlCommand, OleDbCommand, OdbcCommand, OracleCommand)
3.The DataReader object (SqlDataReader, OleDbDataReader, OdbcDataReader, OracleDataReader)
4.The DataAdapter object (SqlDataAdapter, OleDbDataAdapter, OdbcDataAdapter, OracleDataAdapter).
DataSet object represents a disconnected cache of data which is made up of DataTables and DataRelations that represent the result of the command.
Ques: 11 Define Dataset in ADO.Net?
Ans:
Dataset is:
1.Disconnected Recordset objects similar to an array.
2.Supports disconnected data access and operations.
3.Scalability, Provide greater scalability because users no longer have to be connected to the database all the time.
DataSet object is made up of two objects:
1.DataTableCollection object containing null or multiple DataTable objects
2.DataRelationCollection object containing null or multiple DataRelation objects which establish a parent/child relation between two DataTable objects.
Ques: 12 Define types of Datasets in ADO.Net?
Ans:
There are two type of dataset in Ado.net:
1.Typed DataSet: Typed DataSet is derived from the base DataSet class and then uses information in an XML Schema file (.xsd file) in order to generate a new class.
Create a typed DataSet without designer - manually
a.Call the command prompt (cmd) at the location of the XSD schema file.
b.Use the XSD.EXE utility to create the class for the typed DataSet.
2.Untyped DataSet : Untyped DataSet is not defined by a schema, instead, you have to add tables, columns and other elements to it yourself, either by setting properties at design time or by adding them at run time.
Ques: 13 Define the ways to populate a Dataset in ADO.Net?
Ans:
There are following way to populate Dataset:
a.By using DataAdapter objects and Fill method.
b.By creating DataTable, DataColumn and DataRow objects programmatically.
c.Read an XML document or stream into the DataSet.
d.Merge (copy) the contents of another DataSet, with the Merge method.
Ques: 14 Define DataAdapter in ADO.Net?
Ans:
DataAdapter object is links the database and a Connection object with the ADO.NET-managedDataSet object through its SELECT and action query Commands. Means it works like a bridge DataAdapter specified that which data is to move into and out of the DataSet. DataAdapter provide references to SQL statements or stored procedures that are invoked to read or write to a database.
The DataAdapter provides four properties that allow us to control how updates are made to the server:
SelectCommand
UpdateCommand
InsertCommand
DeleteCommand
Ques: 15 Define methods of DataAdapter in ADO.Net?
Ans:
The DataAdapter includes three main methods:
1.Fill (populates a DataSet with data).
2.FillSchema (queries the database for schema information that is necessary to update).
3.Update (to change the database, DataAdapter calls the DeleteCommand, the InsertCommand and the UpdateCommand properties).
Ques: 16 How to DataBindings for TextBoxes in ADO.Net?
Ans:
To bind some elements of a data source with some graphical elements of an application, this ability known as DataBinding. The data in Windows Forms is bound by calling DataBindings. Windows Forms allows you to bind easily to almost any structure that contains data.
Windows Forms Controls support two types of data binding:
a.Simple Data Binding: To display a single data element, means to display a column value from a DataSet table, in a control. It is possible to bind any property of a control to a given data value. Simple Data Binding can be performedby two ways:
1.At design time using DataBindings property of a control
2.Dynamically at run time. This is the type of binding typical for controls such as a TextBox control or Label control that displays typically only a single value.
b.Complex Data Binding: To bind more than one data element, typically more than one record in a database, or to more than one of any other type of bindable data element. DataGrid, ListBox and ErrorProvider controls support complex data binding.
Ques: 17 Define ADO.NET Objects in brief?
Ans:
ADO.net includes many objects you can use to work with data. Some of the primary objects are:
1. The SqlConnection Object
2. The SqlCommand Object
3. The SqlDataReader Object
4. The DataSet Object
5. The SqlDataAdapter Object
Ques: 18 How to Create a SqlConnection Object in Ado.Net?
Ans:
SqlConnection object is like a c# object.The object declare like that:
SqlConnection conn = new SqlConnection(
"Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI");
This argument is called a connection string. It is define as:
Data Source: Identifies the server.
Integrated Security: Set to SSPI to make connection with user's Windows login
User ID: Name of user configured in SQL Server.
Password: Password matching SQL Server User ID.
Using a SqlConnetion the connection creates as:
1.Instantiate the SqlConnection.
2.Open the connection.
3.Pass the connection to other ADO.NET objects.
4.Perform database operations with the other ADO.NET objects.
5.Close the connection.
Ques: 19 How to create a SqlCommand Object in ADO.Net?
Ans:
SqlCommand cmd = new SqlCommand("select CategoryName from Categories", conn);
Above syntax is written to instantiating a SqlCommand object. It takes a string parameter that holds the command you want to execute and a reference to a SqlConnection object.
Ques: 20 How to querying in ADO.Net, when using SqlCommand?
Ans:
Instantiate a new command with a query and connection
SqlCommand cmd = new SqlCommand("select CategoryName from Categories", conn);
Call Execute reader to get query results
SqlDataReader rdr = cmd.ExecuteReader();
Passing the command string and connection object to the constructor. Then we obtain a SqlDataReader object by calling the ExecuteReader method of the SqlCommand object, cmd.
Goto Page:
1
2
ADO.net Objective
ADO.net Objective Questions And Answers
ADO.net Interview Questions And Answers
ADO.net Interview Questions And Answers
R4R,ADO.net Objective, ADO.net Subjective, ADO.net Interview Questions And Answers,ADO.net,ADO.net Interview,ADO.net Questions ,ADO.net Answers