MCQs > Database Management > ADO.NET MCQs > Basic ADO.NET MCQs

Basic ADO.NET MCQ

1. How you can you verify whether a dataset has changed?

Answer

Correct Answer: dataset.HasChanges

Note: This Question is unanswered, help us to find answer for this one

2. 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"?

Answer

Correct Answer: dGrid.DataSource = DataSet.Tables(1)

Note: This Question is unanswered, help us to find answer for this one

3. You have got the data view of the customer table named "ViewCust". Before displaying the records in the grid, you want to retrieve the CustomerIDs with a value less than 50. How will you do this?

Answer

Correct Answer: ViewCust.RowFilter = "CustomerID > 50"

Note: This Question is unanswered, help us to find answer for this one

4. Which of the following is capable of returning multiple rows and multiple columns from the database?

Answer

Correct Answer: All of the above 

Note: This Question is unanswered, help us to find answer for this one

5. You are using Visual Basic to retrieve class information from a Microsoft SQL Server database named ClassList. The database resides on a server named Neptune. Which code fragment will create a connection to this data source?

Answer

Correct Answer: Set conn = New SqlConnection; With conn ; .Provider = "SqlOleDB" ; ConnectionString ="User ID=sa;"&& "Data Source=Neptune;"&& "Initial Catalog=ClassList"

Note: This Question is unanswered, help us to find answer for this one

6. Which of the following is not true about CommandType.TableDirect?

Answer

Correct Answer: TableDirect does not accept table as a parameter

Note: This Question is unanswered, help us to find answer for this one

7. A stored procedure called "FirstQTR" is used for generating the sales report of the first quarter. Apart from other data, it returns the total sale seperately to make a hyperlink. For this purpose you pass a parameter, TotalSale. Which of the following statements suits for the parameter TotalSale?

Answer

Correct Answer: sqlComm.Parameters.Add(TotalSale).Direction = ParameterDirection.Output

Note: This Question is unanswered, help us to find answer for this one

8. 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?

Answer

Correct Answer: Return the result as three out parameters and command object

Note: This Question is unanswered, help us to find answer for this one

9. Which of the following is not a valid member of DataAdapter?

Answer

Correct Answer: AcceptChanges

Note: This Question is unanswered, help us to find answer for this one

10. Which of the following statements is incorrect with regard to a CommandBuilder object?

Answer

Correct Answer: It creates efficient queries in terms of performance

Note: This Question is unanswered, help us to find answer for this one

11. Which of the following is not a member of the CommandType enumeration?

Answer

Correct Answer: Table

Note: This Question is unanswered, help us to find answer for this one

12. Which of the following statements is incorrect with regard to ADO?

Answer

Correct Answer: ADO navigation approach is non-sequential, whereas in ADO.NET it's sequential

Note: This Question is unanswered, help us to find answer for this one

13. Which of the following are used for database connections between SQL Server and ASP.NET?

Answer

Correct Answer: SqlParameterCollection

Note: This Question is unanswered, help us to find answer for this one

14. Which of the following is not associated with the command  object in ADO.NET 2.0?

Answer

Correct Answer: cmd.ExecutePageReader()

Note: This Question is unanswered, help us to find answer for this one

15. Which of the following options is ideally suited for managing database connections?

Answer

Correct Answer: Close the connection as soon as database operation is done

Note: This Question is unanswered, help us to find answer for this one

16. Read the following statements: DataRow oDetailsRow = oDS.Tables["OrderDetails"].Row(); oDetailsRow["ProductId"] = 1; oDetailsRow["ProductName"] = "Product 1"; What is wrong in this code?

Answer

Correct Answer: Row is not a method of the Tables collection

Note: This Question is unanswered, help us to find answer for this one

17. 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?

Answer

Correct Answer: None of the above

Note: This Question is unanswered, help us to find answer for this one

18. Which of the following methods ensures optimum use of Connection Pooling?

Answer

Correct Answer: By using a current user's login for authentication and using 'common account login' for getting the connection

Note: This Question is unanswered, help us to find answer for this one

19. Read the following statement: DataTable.Select (String, String) Here, the first parameter accepts a criteria for filtration, what does the second parameter do?

Answer

Correct Answer: Specifies the sort order

Note: This Question is unanswered, help us to find answer for this one

20. You are developing a website that has four layers. The layers are: user interface (web pages), business objects, data objects, and the database. You want to pass data from the database to controls on a web form. What should you do?

Answer

Correct Answer: 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

Note: This Question is unanswered, help us to find answer for this one

21. 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?

Answer

Correct Answer: It is unfiltered and contains references to the records included in the table

Note: This Question is unanswered, help us to find answer for this one

22. Which of the following is not correct with regard to DataReader and DataSet?

Answer

Correct Answer: DataReader closes its connection automatically 

Note: This Question is unanswered, help us to find answer for this one

23. You have a table named "FirstQTR" and want to create another table "SecondQTR" which is exactly the same as "FirstQTR", including DataTable schema and constraints. Which of the following methods fulfills the requirement?

Answer

Correct Answer: Clone

Note: This Question is unanswered, help us to find answer for this one

24. You have to update some values in the database. Which of the following methods would you execute on a command object named "cmdUpdate?"

Answer

Correct Answer: cmdUpdate.ExecuteNonQuery()

Note: This Question is unanswered, help us to find answer for this one

25. Read the following statement: DataTable.Merge (DataTable, Boolean) What is the boolean parameter?

Answer

Correct Answer: Indicates whether to preserve changes in the current DataTable

Note: This Question is unanswered, help us to find answer for this one

26. In .Net application, you have to update 40 records together in the update query. Previous versions of ADO.NET would be making 40 calls to database. Which of the following parameters is set to 40 with version 2.0?

Answer

Correct Answer: DataAdapter.UpdateBatchSize

Note: This Question is unanswered, help us to find answer for this one

27. Asynchronous execution is supported in ADO.NET 2.0 for ExecuteReader, ExecuteScalar, and ExecuteNonQuery.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

28. Which of the following statements are correct? (a)SQL statements are generally faster than stored procedures (b)The database engine works out the execution plan for SQL statements at run time

Answer

Correct Answer: Only (b) is true

Note: This Question is unanswered, help us to find answer for this one

29. Read the following statements: OleDbDataAdapter oOrderDetailsDataAdapter; OleDbCommandBuilder oOrderDetailsCmdBuilder = New OleDbCommandBuilder(oOrderDetailsDataAdapter); oOrderDetailsDataAdapter.FillSchema(oDS, SchemaType.Source); What is wrong in this code?

Answer

Correct Answer: oOrderDetailsDataAdapter has not been instantiated

Note: This Question is unanswered, help us to find answer for this one

30. How can you make a data reader close connection automatically?

Answer

Correct Answer: command.ExecuteReader(CommandBehavior.CloseConnection)

Note: This Question is unanswered, help us to find answer for this one

31. You have defined a command named "cmdA" 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?

Answer

Correct Answer: trans = con.BeginTransaction()
cmdA.Transaction = trans
cmdA.ExecuteNonQuery()

Note: This Question is unanswered, help us to find answer for this one

32. Which of the following implements IDataReader interface?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

33. Read the following statements:
DataRow oDetailsRow = oDS.Table["OrderDetails"].NewRow();
oDetailsRow["ProductId"] = 1;
oDetailsRow["ProductName"] = "Product 1";
What is wrong with this code?

Answer

Correct Answer: Table is not a collection of DataSet

Note: This Question is unanswered, help us to find answer for this one

34. You have defined an SQL Command object named "sqlComm" to run a stored procedure. The OUT parameter is as follows:
Dim pm2 As New SqlParameter("@Amount," SqlDbType.Money)
How will you add the OUT parameter named pm2 to the command object?

Answer

Correct Answer: sqlComm.Parameters.Add(pm2).Direction = ParameterDirection.Output

Note: This Question is unanswered, help us to find answer for this one

35. Which of the following command types are provided by an oledb and sql provider?

Answer

Correct Answer: StoredProcedure,Text, TableDirect

Note: This Question is unanswered, help us to find answer for this one

36. Which of the following options should you use to copy the edited rows from a dataset called ProductInfo into another dataset called Product Changes?

Answer

Correct Answer: productChanges = productInfo.GetChanges()

Note: This Question is unanswered, help us to find answer for this one

37. Which of the following was not among the main design goals behind ADO NET?

Answer

Correct Answer: To support COM directly

Note: This Question is unanswered, help us to find answer for this one

38. You have two parent and child data tables named "DTOrder" and "DTOrderDetail" respectively. Both are stored in a data set named "DS." How will you make a relation "DTOrder2DTOrderDetail" between the two, using "OrderId" as primary key?

Answer

Correct Answer: DS.Relations.Add(DS.Tables["DTOrder"].Columns["OrderId"], DS.Tables["DTOrderDetail"].Columns["OrderId"]), 3.DS.Relation.Add("DTOrder2DTOrderDetail",

Note: This Question is unanswered, help us to find answer for this one

39. You have to retrieve the details of some members from the "Member" table. The data reader is executed to get the values. Which of the following helps go through the results?

Answer

Correct Answer: DataReader.Read

Note: This Question is unanswered, help us to find answer for this one

40. 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?

Answer

Correct Answer: DataReader 

Note: This Question is unanswered, help us to find answer for this one

41.

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?

Answer

Correct Answer: DTable.GetChanges(DataRowState.Modified)

Note: This Question is unanswered, help us to find answer for this one

42. 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?"

Answer

Correct Answer: DatTab.Compute("Sum(Price)", "SalemanID = 2201")

Note: This Question is unanswered, help us to find answer for this one

43. ADO.NET is known for disconnected data extraction. Which of the following does not use the disconnected mechanism while extracting data from the database?

Answer

Correct Answer: DataReader

Note: This Question is unanswered, help us to find answer for this one

44. 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?

Answer

Correct Answer: System.IO.TextStream

Note: This Question is unanswered, help us to find answer for this one

search
ADO.NET Subjects