What is ADO.NET primarily used for?
a. Data access and manipulation
b. User interface design
c. Web page layout
d. Session management
Answer: a. Data access and manipulation
Which class in ADO.NET is used to connect to a SQL Server database?
a.
SqlConnection
b.
SqlCommand
c.
SqlDataAdapter
d.
SqlDataReader
Answer: a.
SqlConnection
How do you execute a SQL query and return a single value in ADO.NET?
a. Using
SqlCommand.ExecuteScalar()
b. Using
SqlCommand.ExecuteNonQuery()
c. Using
SqlCommand.ExecuteReader()
d. Using
SqlDataAdapter.Fill()
Answer: a. Using
SqlCommand.ExecuteScalar()
What method of
SqlCommand
is used to execute a command that does not return any data?
a.
ExecuteNonQuery()
b.
ExecuteReader()
c.
ExecuteScalar()
d.
ExecuteXmlReader()
Answer: a.
ExecuteNonQuery()
What is the role of the
SqlDataAdapter
class in ADO.NET?
a. To fill a
DataSet
or
DataTable
with data from a database
b. To open and manage database connections
c. To execute SQL commands
d. To read data from a database
Answer: a. To fill a
DataSet
or
DataTable
with data from a database
Which class provides a forward-only, read-only cursor for reading data?
a.
SqlDataReader
b.
SqlDataAdapter
c.
SqlConnection
d.
SqlCommand
Answer: a.
SqlDataReader
How can you handle transactions in ADO.NET?
a. By using the
SqlTransaction
class
b. By setting
TransactionScope
in
SqlCommand
c. By configuring transactions in
SqlConnection
d. By using
DataSet
transactions
Answer: a. By using the
SqlTransaction
class
What is the purpose of the
DataSet
class in ADO.NET?
a. To hold data in memory in a tabular format
b. To manage database connections
c. To execute SQL queries
d. To handle transactions
Answer: a. To hold data in memory in a tabular format
Which ADO.NET object is used to fill a
DataSet
with data from a database?
a.
SqlDataAdapter
b.
SqlConnection
c.
SqlCommand
d.
SqlDataReader
Answer: a.
SqlDataAdapter
What method of
SqlCommand
is used to execute a query and return a
DataReader
object?
a.
ExecuteReader()
b.
ExecuteNonQuery()
c.
ExecuteScalar()
d.
ExecuteXmlReader()
Answer: a.
ExecuteReader()
How do you update a database using a
DataSet
in ADO.NET?
a. By calling
DataAdapter.Update()
b. By calling
DataSet.Update()
c. By calling
SqlCommand.ExecuteNonQuery()
d. By calling
SqlDataAdapter.Fill()
Answer: a. By calling
DataAdapter.Update()
What class is used to perform batch operations in ADO.NET?
a.
SqlDataAdapter
b.
SqlBulkCopy
c.
SqlCommand
d.
SqlTransaction
Answer: b.
SqlBulkCopy
Which method in
SqlCommand
is used to execute a SQL command and return a single object?
a.
ExecuteScalar()
b.
ExecuteNonQuery()
c.
ExecuteReader()
d.
ExecuteXmlReader()
Answer: a.
ExecuteScalar()
What does the
Fill()
method of
SqlDataAdapter
do?
a. Populates a
DataSet
or
DataTable
with data from the database
b. Executes a SQL command
c. Opens a database connection
d. Reads data from a database
Answer: a. Populates a
DataSet
or
DataTable
with data from the database
Which ADO.NET class is used to manage connections to a database?
a.
SqlConnection
b.
SqlCommand
c.
SqlDataAdapter
d.
SqlDataReader
Answer: a.
SqlConnection
How do you handle errors during database operations in ADO.NET?
a. By using try-catch blocks
b. By using the
SqlException
class
c. By checking the
HasRows
property of
DataReader
d. By validating
DataSet
changes
Answer: a. By using try-catch blocks
What is the default command behavior of
SqlCommand
when executing a query?
a. It returns a result set
b. It performs an update operation
c. It opens a new database connection
d. It executes a stored procedure
Answer: a. It returns a result set
Which class in ADO.NET provides functionality for reading XML data?
a.
XmlReader
b.
SqlDataReader
c.
SqlDataAdapter
d.
SqlCommand
Answer: a.
XmlReader
What is the purpose of the
DataRow
class in ADO.NET?
a. To represent a single row in a
DataTable
b. To execute SQL queries
c. To manage database connections
d. To fill a
DataSet
with data
Answer: a. To represent a single row in a
DataTable
Which method of
SqlConnection
is used to open a connection to the database?
a.
Open()
b.
Connect()
c.
Begin()
d.
Start()
Answer: a.
Open()
What is the purpose of
DataTable
in ADO.NET?
a. To represent a single table of in-memory data
b. To execute a SQL command
c. To manage database connections
d. To handle database transactions
Answer: a. To represent a single table of in-memory data
How can you execute a stored procedure using ADO.NET?
a. By setting the
CommandType
property of
SqlCommand
to
StoredProcedure
b. By using the
SqlDataAdapter
class
c. By using the
DataSet
class
d. By using the
SqlConnection
class
Answer: a. By setting the
CommandType
property of
SqlCommand
to
StoredProcedure
Which method of
SqlDataReader
is used to read the next row of data?
a.
Read()
b.
Next()
c.
Fetch()
d.
MoveNext()
Answer: a.
Read()
What is the role of
SqlTransaction
in ADO.NET?
a. To manage transactions within a database connection
b. To execute SQL commands
c. To open a database connection
d. To read data from a database
Answer: a. To manage transactions within a database connection
Which property of
SqlDataAdapter
is used to specify the SQL command to execute?
a.
SelectCommand
b.
CommandText
c.
CommandType
d.
Connection
Answer: a.
SelectCommand
How can you specify a SQL query parameter in ADO.NET?
a. By using
SqlParameter
class
b. By including the parameter directly in the SQL query string
c. By setting the
CommandText
property
d. By configuring parameters in
SqlConnection
Answer: a. By using
SqlParameter
class
What does the
ExecuteNonQuery()
method of
SqlCommand
return?
a. The number of rows affected by the command
b. The result set from the command
c. A single value from the command
d. A
DataReader
object
Answer: a. The number of rows affected by the command
Which class in ADO.NET is used to fill a
DataSet
with data from multiple tables?
a.
SqlDataAdapter
b.
SqlConnection
c.
SqlCommand
d.
SqlDataReader
Answer: a.
SqlDataAdapter
What does the
Close()
method of
SqlConnection
do?
a. Closes the connection to the database
b. Cancels the current transaction
c. Rolls back the current transaction
d. Stops the execution of a command
Answer: a. Closes the connection to the database
Which method of
DataSet
is used to merge changes from a
DataTable
?
a.
Merge()
b.
Update()
c.
AcceptChanges()
d.
Refresh()
Answer: a.
Merge()
What is
DataReader
used for in ADO.NET?
a. To read data in a forward-only, read-only manner
b. To fill a
DataSet
with data
c. To execute commands against the database
d. To manage database connections
Answer: a. To read data in a forward-only, read-only manner
Which class in ADO.NET is used to execute SQL commands and retrieve results?
a.
SqlCommand
b.
SqlConnection
c.
SqlDataAdapter
d.
SqlDataReader
Answer: a.
SqlCommand
How can you retrieve schema information from a database using ADO.NET?
a. By using the
GetSchema()
method of
SqlConnection
b. By using
SqlDataAdapter
c. By using
SqlCommand
d. By using
DataSet
Answer: a. By using the
GetSchema()
method of
SqlConnection
What is the function of
SqlBulkCopy
class in ADO.NET?
a. To efficiently bulk copy data from one data source to another
b. To execute SQL commands
c. To read data from a database
d. To fill a
DataSet
with data
Answer: a. To efficiently bulk copy data from one data source to another
How do you handle concurrency issues in ADO.NET?
a. By using
RowVersion
or
Timestamp
columns
b. By disabling transactions
c. By using
DataReader
d. By configuring isolation levels in
SqlConnection
Answer: a. By using
RowVersion
or
Timestamp
columns
Which property of
SqlCommand
is used to specify whether a command is a stored procedure or a SQL query?
a.
CommandType
b.
CommandText
c.
Parameters
d.
Connection
Answer: a.
CommandType
What does the
FillSchema()
method of
SqlDataAdapter
do?
a. Fills the
DataSet
with schema information only
b. Executes a SQL command
c. Fills the
DataSet
with data
d. Updates the
DataSet
with changes
Answer: a. Fills the
DataSet
with schema information only
Which class provides methods for managing the database connection pool in ADO.NET?
a.
SqlConnection
b.
SqlConnectionStringBuilder
c.
SqlCommand
d.
SqlDataAdapter
Answer: a.
SqlConnection
What is the default behavior of
DataSet
when changes are made to its rows?
a. Changes are tracked and can be updated to the database
b. Changes are automatically committed to the database
c. Changes are discarded
d. Changes are saved in a new
DataSet
Answer: a. Changes are tracked and can be updated to the database
What does the
GetChanges()
method of
DataSet
return?
a. A copy of the
DataSet
with changes
b. The number of rows changed
c. The schema of the
DataSet
d. The original
DataSet
Answer: a. A copy of the
DataSet
with changes
Which class in ADO.NET is used for accessing and updating XML data?
a.
XmlDataAdapter
b.
SqlDataAdapter
c.
DataTable
d.
DataSet
Answer: a.
XmlDataAdapter
What is the purpose of
DataTableReader
in ADO.NET?
a. To provide a forward-only, read-only cursor for reading data from a
DataTable
b. To manage database connections
c. To execute SQL commands
d. To update a
DataSet
Answer: a. To provide a forward-only, read-only cursor for reading data from a
DataTable
Which ADO.NET class is designed for asynchronous database operations?
a.
SqlCommand
with async methods
b.
SqlDataAdapter
c.
SqlConnection
d.
DataSet
Answer: a.
SqlCommand
with async methods
What is the function of the
UpdateCommand
property of
SqlDataAdapter
?
a. It specifies the SQL command used to update the database with changes from a
DataSet
b. It specifies the SQL command to delete records
c. It specifies the SQL command to insert new records
d. It specifies the SQL command to select records
Answer: a. It specifies the SQL command used to update the database with changes from a
DataSet
How can you perform batch updates to a database using ADO.NET?
a. By using
SqlDataAdapter
with multiple commands
b. By using
SqlCommand
with
Transaction
c. By using
SqlBulkCopy
d. By using
DataTable
with
DataSet
Answer: c. By using
SqlBulkCopy
What is the purpose of
DataColumn
in ADO.NET?
a. To represent a single column in a
DataTable
b. To execute a SQL command
c. To manage database connections
d. To handle transactions
Answer: a. To represent a single column in a
DataTable
How does ADO.NET handle data in disconnected mode?
a. By using
DataSet
and
DataTable
to store data locally
b. By maintaining an open connection throughout the data access
c. By using
SqlDataReader
in an open connection
d. By using
DataAdapter
to fill data directly
Answer: a. By using
DataSet
and
DataTable
to store data locally