Friday, June 10, 2016

ADO.NET 2003 Test Answer

ADO.NET 2003 Test Answer

Read the following statement:

DataTable.Merge (DataTable, Boolean)

What is the boolean parameter?
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
We are iterating through the results received in a data reader named 'DReaderOrder,' which is created by using the connection 'SqlCon.' In between we need to retrieve some more values from the database, so we executed another command in the same connection to get the results in a new data reader named 'DReaderProduct.' What will be the result if we are using ADO.NET 2.0? (Note:Multiple Active Result Sets (MARS) is enabled in SQL Server 2005).
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'
Which of the following is not true about CommandType.TableDirect?
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
Read the following statements:

        Dim employeeDS As DataSet
     
        employeeDS.Tables.Add(new DataTable("FirstQTR"))
What will be the result of above code?
a. It will create a table named FirstQTR
b. It does nothing because the object reference is not set to an instance of the dataset object
c. It will produce an error because the object reference is not set to an instance of the dataset object
d. None of the above
You have got a supplier data table named "DTSupp." To display records specifically with sorting, you employed a dataview as follows:
Dim DataViewSupp As DataView = DTSupp.DefaultView
What is the 'DataViewSupp' table view by default?
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
You have following data table structure:
Sales
-----------
SalemanId
OrderId
Price
How will you calculate the total amount generated by a salesman (with SalemanID =2201) if the name of DataTable is 'DatTab?'
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)")
Read the following statements:
OleDbDataAdapter oOrderDetailsDataAdapter;
OleDbCommandBuilderoOrderDetailsCmdBuilder= New  OleDbCommandBuilder(oOrderDetailsDataAdapter);
oOrderDetailsDataAdapter.FillSchema(oDS, SchemaType.Source);
What is wrong in this code?
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
Which of the following options is ideally suited for managing database connections?
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
Which of the following statements is incorrect with regard to a CommandBuilder object?
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
You have an Odbc connection to the database. You want to pass a parameter named 'ProductName' of type Varchar to the select command object. If the product name to be passed is "Notebook", how will you do that with a data adapter named 'ADP?'
a. ADP.SelectCommand.Parameters.Add("@ProductName", OdbcType.VarChar, 80).Value = "Notebook";
b. ADP.SelectCommand.Parameters.Add("@ProductName", Type.VarChar, 80) = "Notebook";
c. ADP.SelectCommand.Parameter.Add("@ProductName", OdbcType.VarChar, 80).Value = "Notebook";
d. ADP.SelectCommand.Parameter.Add("@ProductName", Type.VarChar, 80) = "Notebook";
You defined a data adapter as follows:
Dim adap As New SqlDataAdapter("select * from products;select * from customers", New SqlConnection(ConnectionString))
Dim DataSet As New DataSet
adap.Fill(DataSet)
How will you pass the customers data to a data grid named as "dGrid"?
a. dGrid.Fill(DataSet.Tables(1))
b. dGrid.Fill(DataSet.Tables(2))
c. dGrid.DataSource = DataSet.Tables(1)
d. dGrid.DataSource = DataSet.Tables(2)
You use a Command object to retrieve employee names from the employee table in the database. Which of the following will be returned when this command is executed using the ExecuteReader method?
a. DataRow
b. DataSet
c. DataTable
d. DataReader
One of your forms displays the list of all the Customers in a list box and all their details in the text boxes. On selecting a Customer in the list box, text boxes should show details of that customer. Which of the following is ideally suited for the purpose?
a. Me.BindingContext(DataSet,TableName).Position
b. Me.BindingContext(TableName, DataSet).Position
c. Me.BindingContext(DataSet,TableName)
d. Me.BindingContext(TableName, DataSet)
You have to update some values in the database. Which of the following methods would you execute on a command object named "cmdUpdate?"
a. cmdUpdate.ExecuteScalar()
b. cmdUpdate.ExecuteNonQuery()
c. cmdUpdate.ExecuteReader()
d. cmdUpdate.Execute()
e. ExecuteXmlReader()
Premium Finance Corp is involved in the savings business with branches all over the country. They provide flexible schemes which can be designed according the client's requirements. A dataset maintains all schemes in separate tables. You want to show all the schemes in different datagrids which should be created in the same sequence as the tables are in dataset. Which of the following is the most suitable method in the current scenario?
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
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)
Which of the following is the parent class of DataAdapter?
a. Component
b. DataSet
c. ComponentModel
d. SqlClient
What are the core components of .Net framework data provider model?
a. DataAdapter and DataReader
b. Connection and Command
c. DataAdapter, Connection, and Command
d. DataAdapter , DataReader, Connection, and Command
Read the following statements:
Dim dr As DataRow
Dim objCustReader As Data.SqlClient.SqlDataReader
Dim dtCustomers As DataTable
With dtCustomers.Columns.Add(New DataColumn("Customer ID")
End With
What is wrong in above code?
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
Read the following statements:
DataRow oDetailsRow = oDS.Table["OrderDetails"].NewRow();
oDetailsRow["ProductId"] = 1;
oDetailsRow["ProductName"] = "Product 1";
What is wrong with this code?
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
We are iterating through the results received in a data reader named 'DReaderOrder,' which is created by using connection 'SqlCon.' In between, we need to retrieve some more values from the database, so we executed another command using 'SqlCon,' to get the results in another data reader 'DReaderProduct.' What will happen if we use ADO.NET 1.1?
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'
ADO.NET 2.0 provides a simple way of copying the complete table from one data source(/database) to another. What is the class providing this functionality known as?
a. BulkCopy
b. SQLBulkCopy
c. OleDbBulkCopy
d. CopyTable
You have defined a command named 'comA' and an open connection named 'con'. You created a new transaction:
Dim trans As SqlClient.SqlTransaction = Nothing
How will you assign the command to the transaction and begin the transaction?
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()
Which of the following is not a valid member of DataAdapter?
a. AcceptChanges
b. acceptchangesDuringFill
c. Container
d. TableMappings
Which of the following is not a valid method of DataAdapter?
a. Fill
b. FillSchema
c. HasChanges
d. Update
Which of the following are valid methods of the SqlTransaction class?
a. Commit
b. Terminate
c. Save
d. Close
e. Rollback
The WriteXml method of a DataSet writes the data of the DataSet in an XML file. WriteXml accepts a parameter for the different types of destinations. Which of the following is an invalid type for the destination?
a. String
b. System.IO.Stream
c. System.IO.TextStream
d. System.IO.TextWriter
e. System.Xml.XmlWriter
Which of the following statements is true with regard to DataRow and DataRowView?
a. The DataRowView object is a wrapper for the reference to the DataRow object
b. The DataRow object can be accessed from a DataRowView
c. Both are safe for multithreaded read operations
d. All of the above
Which of the following implements IDataReader interface?
a. SqlDataReader
b. OleDbDataReader
c. OracleDataReader
d. ODBCDataReader
e. All of the above
Which of the following statements are correct?
(a)A DataReader doesn't have an iterator or a rows collection
(b)When DataReader reaches the last row, its Read() method will return false
a. Only (a) is true
b. Only (b) is true
c. Both (a) and (b) are true
d. Both (a) and (b) are false
How can you make a data reader close connection automatically?
a. command.ExecuteReader()
b. command.ExecuteReader(CommandBehavior.Default)
c. command.ExecuteReader(CommandBehavior.CloseConnection)
d. command.ExecuteReader(CommandBehavior.SingleRequest)
Which of the following statements is correct with regard to transaction?
a. A transaction can have multiple command objects assigned to it
b. A transaction can have only one command object assigned to it
c. One command object must be executed before assigning another command to the transaction
d. A transaction ends with EndTransaction() on connection object
The DataSet object can extract data from an XML file. The ReadXML method accepts the source as a parameter and returns a value from the xmlReadMode enumeration. Which of the following is an invalid option of XmlReadMode?
a. ReadSchema
b. InferSchema
c. IgnoreSchema
d. Fragment
e. DiffGramSchema
Which of the following is not associated with the command��object in ADO.NET 2.0?
a. cmd.ExecuteScalar()
b. cmd.ExecutePageReader()
c. cmd.ExecuteReader()
d. cmd.ExecuteXmlReader()
e. cmd.Execute()
You have added some rows to the existing datatable in the dataset. Which of the following methods would you invoke?
a. DataSet.Merge(NewRows[])
b. DataSet.Add(NewRows[])
c. DataSet.AddRows(NewRows[])
d. DataSet.Include(NewRows[])
Read the following statements:
DataRow oDetailsRow = oDS.Tables["OrderDetails"].Row();
oDetailsRow["ProductId"] = 1;
oDetailsRow["ProductName"] = "Product 1";
What is wrong in this code?
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
Which of the following are invalid values of a Dataset's SchemaSerializationMode property?
a. CreateSchema
b. DeleteSchema
c. IncludeSchema
d. ExcludeSchema
e. None of the above
You must create a stored procedure to retrieve the following details for the given customer:
CustomerName, Address, PhoneNumber
Which of the following is an ideal choice to get the result?
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
Which of the following statements is incorrect with regard to ADO?
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
ADO.NET 2.0 has a new feature that allows you to run more than one DataReader from the same connection at the same time. Which of the following properties must be true for multiple DataReaders?
a. MUDR
b. OMDR
c. MARS
d. MDRC

No comments:

Post a Comment