1.What is Microsoft ADO.NET?
Visual
Studio .NET provides access to databases through the set of tools and namespaces collectively
referred to as Microsoft ADO.NET
2. What are the 3 major types of connection
objects in ADO.NET?
OleDbConnection object : Use an OleDbConnection object to connect to a Microsoft Access or third-party database, such as MySQL. OLE database connections use the OleDbDataAdapter object to perform commands and return data.
SqlConnection object : Use a SqlConnection object to connect to a Microsoft SQL Server database. SQL database connections use the SqlDataAdapter object to perform commands and return data.
OracleConnection object : Use an OracleConnection object to connect to Oracle databases. Oracle database connections use the OracleDataAdapter object to perform commands and return data. This connection object was introduced in Microsoft .NET Framework version 1.1.
3.List the 4 common ADO.NET Namespaces?
System.Data : Contains Classes, types, and services for creating and accessing data sets and their subordinate objects.
System.Data.SqlClient : Contains Classes and types for accessing Microsoft SQL Server databases.
System.Data.OracleClient : Contains Classes and types for accessing Oracle databases (Microsoft .NET Framework version 1.1 and later).
System.Data.OleDb : Contains Classes and types for accessing other databases
4 What
is the difference between Data Reader and Data Adapter?
1. Data Reader is read only forward only and much faster than Data Adapter.
2. If you use Data Reader you have to open and close connection explicitly where as if you use Data Adapter the connection is automatically opened and closed.
3. Data Reader is connection oriented where as Data Adapter is disconnected.
5.Will the connection be closed, if the
SqlConnection object goes out of scope?
No, If the SqlConnection goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling Close or Dispose.
6.How do you read an XML file into a DataSet?
Using the DataSet object’s ReadXML method.
7.When do you use ExecuteReader, ExecuteNonQuery,
ExecuteScalar methods?
If the command or stored procedure that is being executed
returns a set of rows, then
we use ExecuteReader method.
If the command or stored procedure that is being executed returns a single value then
we use ExecuteScalar method.
If the command or stored procedure performs INSERT, DELETE or UPDATE operations, then
we use ExecuteNonQuery method. ExecuteNonQuery method
returns an integer specifying the number of rows inserted, deleted or
updated.
8.How
can you identify the updated rows in a dataset?
Using
Rowstate property of the DataRow.If the RowState property of the DataRow is
"Modified" then that
DataRow can be treated as updated.
9.what
is capacity of dataset?
DataSet is logical represantation of database so it can store
as much as database.
10 Can your class inherit from
SqlCommand Class?
No, you cannot inheirt from SqlCommand Class. SqlCommand Class is a sealed class. It is a compile time error.
11.What is Source?
It can be a database, text file, excel spread sheet or an
XML file.
12.What is dataprovider?
A set of libraries that is used to communicate
with data source. Eg: SQL data provider for SQL, Oracle data provider
for Oracle, OLE DB data provider for access, excel or mysql.
13.What is SqlCommand?
It allows to manipulate database by executing stored
procedure or sql statements.
14.What is DataReader?
It provides a
forward-only, read-only, connected recordset.
15.What is DataSet?
Dataset is a disconnected, in-memory representation of
data. It can
contain multiple data table from different database.
16.What is SQL DataAdapter?
It populates
dataset from data source. It
contains a reference to the connection object and opens and closes the
connection automatically when reading from or writing to the database.
17.what is DataView?
It provides a
means to filter and sort data within a data table.
21.What is the use of connection
object?
It is used to connect a data to a Command object. An OleDbConnection object is used with an OLE-DB provider A SqlConnection object uses Tabular Data Services (TDS) with MS SQL Server
22.What is the use of data
adapter?
These objects connect one or more Command objects to a Dataset object. They provide logic that would get data from the data store and populates the tables in the Dataset, or pushes the changes in the Dataset back into the data store. An OleDbDataAdapter object is used with an OLE-DB provider .A SqlDataAdapter object uses Tabular Data Services with MS SQL Server.
23. What
is connection pooling?
Connection pooling refers to the task of grouping database connections
in cache to make them reusable because opening new connections every time to
a database is a time-consuming process. Therefore, connection pooling enables
you to reuse already existing and active database connections, whenever
required, and increasing the performance of your application.
You can enable or disable connection pooling in your application by setting the pooling property to either true or false in connection string. By default, it is enabled in an application.
24.Difference
between dataset and datareader?
Dataset:
DataSet
object can contain multiple rowsets from the same data source as well as from
the relationships between them.
Dataset
is a disconnected architecture.
Dataset
can persist data.
Datareader:
DataReader
provides forward-only and read-only access to data.
Datareader
is connected architecture.
Datareader
can not persist data.
25 Which properties are used to bind a DataGridView control?
The DataSource property and the DataMember property
are used to bind a DataGridView control.
26 What is the difference between the Clone() and
Copy() methods of the DataSet class?
The Clone() method
copies only the structure of a DataSet. The copied structure
includes all the relation, constraint, and DataTable schemas used by the DataSet.
TheClone() method does not copy the data, which is stored in theDataSet.The Copy() method
copies the structure as well as the data stored in the DataSet.
27 What
are basic methods of a DataAdapter?
Fill
FillSchema
Update
28
How can we connect to Microsoft Access ,Foxpro , Oracle etc ?
Microsoft
provides System.Data.OleDb namespace to communicate with databases like
Access, Oracle etc. In short any OLE DB-Compliant database can be connected
using System.Data.OldDb namespace.
29 Which
is the best place to store connectionstring in .NET projects?
Config
files are the best places to store connectionstrings. If it is a web-based
application “Web.config” file will be used and if it is a windows application
“App.config” files will be used.
30
How can we save all data from dataset ?
Dataset
has “AcceptChanges” method which commits all the changes since last time
“Acceptchanges” has been executed.
31 Can you edit data in the
Repeter control?
No, it just reads the information
from its data source
32 Can DataAdapter object accept DataTable as parameter in Fill method?
DataAdapter
object can accept either DataTable or DataSet as parameter to fill data from
database.
33 Which
is better data reader or dataset?
It
depends upon the requirement .whenever we need only access data, DataReader
is better.
34 Which adapter should you
use, if you want to get the data from an Access database?
OleDbDataAdapter is used to get the data from an
Access database.
35 How do we use stored procedure in ADO.NET and how do we provide
parameters to the stored procedures?
ADO.NET
provides the SqlCommand object, which provides the functionality of executing
stored procedures
|
No comments:
Post a Comment