These ADO.NET multiple-choice questions and their answers will help you strengthen your grip on the subject of ADO.NET. You can prepare for an upcoming exam or job interview with these 50+ ADO.NET MCQs.
So scroll down and start answering.
A. String
B. System.IO.Stream
C. System.IO.TextStream
D. System.IO.TextWriter
E. System.Xml.XmlWriter
A. DataAdapter
B. DataReader
C. DataSet
D. None of the above
A. DatTab.Calculate("Sum(Price)", "SalemanID = 2201")
B. DatTab.Compute("Sum(Price)", "SalemanID = 2201")
C. DatTab.Calculate("SalemanId = 2201","Sum(Price)")
D. DatTab.Compute("SalemanId = 2201","Sum(Price)")
You have a data table named "DTable."Â You are writing a sub routine to validate the changes made by the user. Which of the following would you use to get the changed table data?
A. DTable.GetChanges(DataRowState.Modified)
B. DTable.GetChanges(DataRowsModified)
C. DTable.TableChanges(DataRowState.Modified)
D. DTable.TableChanges(DataRowsModified)
A. cmd.ExecuteScalar()
B. cmd.ExecuteNonQuery()
C. cmd.ExecuteReader()
D. cmd.Execute()Â
A. DataRow
B. DataSet
C. DataTable
D. DataReaderÂ
A. DataReader.Next
B. DataReader.Move
C. DataReader.Read
D. DataReader.MoveNext
A. DS.Relation.Add(DS.Tables["DTOrder"].Columns["OrderId"], DS.Tables["DTOrderDetail"].Columns["OrderId"]), 2.DS.Relations.Add("DTOrder2DTOrderDetail",
B. DS.Relations.Add(DS.Tables["DTOrder"].Columns["OrderId"], DS.Tables["DTOrderDetail"].Columns["OrderId"]), 3.DS.Relation.Add("DTOrder2DTOrderDetail",
C. DS.Relation.Add(DS.Tables["DTOrderDetail"].Columns["OrderId"], DS.Tables["DTOrder"].Columns["OrderId"]), 4.DS.Relations.Add("DTOrder2DTOrderDetail",
D. DS.Relations.Add(DS.Tables["DTOrderDetail"].Columns["OrderId"], DS.Tables["DTOrder"].Columns["OrderId"])">
A. To provide seamless support for XML
B. To support COM directly
C. To provide an expandable and scalable data access architecture for the revolutionary n-tier programming model
D. To extend the current capabilities of ADOÂ
A. productChanges = productInfo.GetChanges(DataRowState.Detached)
B. productChanges = productInfo.GetChanges()
C. productChanges.Merge(productInfo, true)
D. productChanges.Merge(productInfo, false)Â
A. StoredProcedure,Text, TableDirect
B. StoredProcedure,Query, TableDirect
C. Procedure,Text,Table,Query
D. Procedure,Query, TableDirect
A. sqlComm.Parameters.Add(pm2)
B. sqlComm.Parameters.Add(pm2).Mode = ParameterMode.Output
C. sqlComm.Parameters.Add(pm2).Direction = ParameterDirection.Output
D. sqlComm.Parameters.Add(pm2).Direction = ParameterDirection.ReturnValueÂ
A. Table is not a collection of DataSet
B. Name of the column can not be passed in the Columns collection
C. NewRow is not a method of the Tables collection
D. None of the aboveÂ
A. SqlDataReader
B. OleDbDataReader
C. OracleDataReader
D. ODBCDataReader
E. All of the above
A. cmdA.Transaction = trans
cmdA.ExecuteNonQuery()
B. trans.BeginTransaction()
cmdA.Transaction = trans
cmdA.ExecuteNonQuery()Â
C. trans = con.BeginTransaction()
cmdA.Transaction = trans
cmdA.ExecuteNonQuery()
D. trans = con.OpenTransaction()
cmdA.Transaction(trans)
cmdA.ExecuteNonQuery()Â
A. command.ExecuteReader()
B. command.ExecuteReader(CommandBehavior.Default)
C. command.ExecuteReader(CommandBehavior.CloseConnection)
D. command.ExecuteReader(CommandBehavior.SingleRequest)
A. The parameters are incorrect for the FillSchema method
B. OleDbCommandBuilder has no constructor
C. oOrderDetailsDataAdapter has not been instantiated
D. None of the above
A. Only (a) is true
B. Only (b) is true
C. Both (a) and (b) are true
D. Both (a) and (b) are false
A. True
B. FalseÂ
A. DataAdapter.UpdateBatchSize
B. DataAdapter.UpdateSize
C. DataAdapter.BatchSize
D. DataAdapter.BatchRecordSizeÂ
A. This is an out parameter and returns the status of merging
B. Determines whether duplicate data should be removed
C. Indicates whether to preserve changes in the current DataTable
D. None of the aboveÂ
A. cmdUpdate.ExecuteScalar()
B. cmdUpdate.ExecuteNonQuery()
C. cmdUpdate.ExecuteReader()
D. cmdUpdate.Execute()
E. ExecuteXmlReader()Â
A. Copy
B. Clone
C. Duplicate
D. EqualsÂ
A. Write a loop for the tables() collection and call CreateDataReader for each table and bind with a dynamically generated datagrid
B. Call GetXMLSchema, create an XML file and then bind with a dynamically generated datagrid
C. Create datagrids for each table and bind with the relevant table
D. None of the aboveÂ
A. DataReader
B. DataAdapter
C. Command object's ExecuteNonQuery
D. DataReader with Command object's ExecuteNonQuery
E. None of the above
A. DataReader reads one row from the database
B. DataSet gets complete set of data from the database
C. DataReader can only get its data from a data source through a managed provider
D. DataReader closes its connection automaticallyÂ
A. It is unfiltered and contains references to the records included in the table
B. It is filtered on ID column and contains references to the records included in the table
C. It is unfiltered and does not contain references to the records included in the table
D. It is filtered on ID column and does not contain references to the records included in the tableÂ
A. Populate the data objects with data from the database. Populate the controls with values retrieved from the data objects
B. Populate the business objects with data from the database. Populate the controls with values retrieved from the business objects
C. Populate the data objects with data from the database. Populate the business objects with data from the data objects. Populate the controls with values retrieved from the business objects
D. Bind the controls directly to the databaseÂ
A. Specifies the sort order
B. Accepts another criteria
C. Specifies the column name which should be searched
D. Header of output
A. By using current user's login for authentication and getting the connection
B. By using a common account login for authentication and getting the connection
C. By using a current user's login for authentication and using 'common account login' for getting the connection
D. None of the aboveÂ
A. Add is not a method of the Columns collection
B. Column collection should be used instead of columns collection
C. The Data Type of the column is a required parameter of 'Add' method
D. None of the above
A. The name of the table can not be passed in the Tables collection
B. The name of the column can not be passed in the Columns collection
C. Row is not a method of the Tables collection
D. None of the aboveÂ
A. Pass the open connection objects between the methods
B. Close the connection as soon as database operation is done
C. Open a global connection and keep on using it without reopening
D. Within a transaction, a connection should be closed in each method and reopened in the other
A. cmd.ExecuteScalar()
B. cmd.ExecutePageReader()
C. cmd.ExecuteReader()
D. cmd.ExecuteXmlReader()
E. cmd.Execute()Â
A. SqlInfoMessageEvent
B. SqlParameterCollection
C. SqlRowUpdatingEvent
D. SqlClientPermissionAttributeÂ
A. ADO uses recordset whereas ADO.NET uses dataset
B. ADO navigation approach is non-sequential, whereas in ADO.NET it's sequential
C. Disconnected access in ADO has to be coded explicitly, whereas ADO.NET handles it with the adapter
D. ADO offers hierarchical RecordSet for relating multiple tables, whereas ADO.NET provides data relationsÂ
A. Table
B. storedProcedure
C. TableDirect
D. TextÂ
A. It creates insert, update, and delete queries on the fly
B. It creates efficient queries in terms of performance
C. A unique column must be selected as a part of the select query
D. It can't work with queries having joinsÂ
A. A DataSet can derive data from a database
B. A DataSet can derive data from an xml file
C. A DataSet can derive data from both xml file and a database
D. A DataSet can be used to view data onlyÂ
E. Datasets store data in a disconnected cache
A. Add the following two lines of code before calling the Update method: Dim cb As New OleDb.OleDbCommandBuilder(da) cb.GetUpdateCommand()Â
B. Add the following line of code before calling the Update method: da.UpdateCommand.Connection.Open()Â
C. Delete this line of code: dataTable.AcceptChanges()Â
D. Delete this line of code: da.Dispose()Â
A. First data reader will immediately stop and new data reader starts reading
B. First data reader will halt till the new data reader finishes reading
C. Both will keep on reading records independent of each other
D. We receive an exception 'Systerm.InvalidOperationException'Â
A. AcceptChanges
B. acceptchangesDuringFill
C. Container
D. TableMappings
A. Return the result as dataset using data adapter
B. Return the result as dataset using command object
C. Return the result as three out parameters and command object
D. All of the above
A. sqlComm.Parameters.Add(TotalSale,Out)
B. sqlComm.Parameters.Add(TotalSale).Mode = ParameterDirection.Output
C. sqlComm.Parameters.Add(TotalSale).Direction =Â Â Parameter.Output
D. sqlComm.Parameters.Add(TotalSale).Direction = ParameterDirection.Output
A. First data reader will immediately stop and new data reader starts reading
B. First data reader will halt till the new data reader finishes reading
C. Both will keep on reading records independent of each other
D. We receive an exception 'System.InvalidOperationException'
A. TableDirect is only supported by the .NET Framework Data Provider for OLE DB
B. Multiple table access is not supported when CommandType is set to TableDirect
C. TableDirect does not accept table as a parameter
D. None of the above
A. Set conn = New SqlConnection; With conn ; .Provider = "SqlOleDB" ; ConnectionString ="User ID=sa;"&& "Data Source=Neptune;"&& "Initial Catalog=ClassList"
B. Set conn = New SqlConnection; With conn ; .Provider = "Neptune" ; ConnectionString ="User ID=sa;"&& "Data Source=Neptune;"&& "Initial Catalog=ClassList"
C. Set conn = New SqlConnection; With conn ; .Provider = "SqlOleDB" ; ConnectionString ="User ID=sa;"&& "Data Source= Neptune;"
A. Return (IIf(IsNull(cm.ExecuteNonQuery), 1, cm.ExecuteNonQuery +1))
B. Return (IIf(IsDBNull(cm.ExecuteScalar), 1, cm.ExecuteScalar +1 ))
C. Return (IIf(IsNull(cm.ExecuteScalar), 1, cm.ExecuteScalar))
D. Return (IIf(IsDBNull(cm.ExecuteNonQuery), cm.ExecuteNonQuery ,1))Â
A. AutoIncrementSeed
B. AutoIncrementStep
C. AutoIncrement
D. AutoIncrementNumber
E. AutoIncrementIndex
A. ExecuteReader
B. ExecuteXmlReader
C. Adapter.fill
D. All of the aboveÂ