In such type of questions interviewer is looking from practical angle, that have youworked with dataset and datadapters. Let me try to explain the above code first and thenwe move to what steps should be told during interview.
Dim objConn As New SqlConnection(strConnectionString)objConn.Open()
First step is to open the connection. Again, note the connection string is loaded fromconfig file.
Dim objCommand As New SqlCommand(“Select FirstName from Employees”)objCommand.Connection = objConn
Second step is to create a command object with appropriate SQL and set the connectionobject to this command.
Dim objDataAdapter As New SqlDataAdapter()objDataAdapter.SelectCommand = objCommand
Third steps is to create the Adapter object and pass the command object to the adapter object.
Fourth step is to load the dataset using the “Fill” method of the data adapter.
lstData.DataSource = objDataSet.Tables(0).DefaultViewlstData.DisplayMember = “FirstName”lstData.ValueMember = “FirstName”
Fifth step is to bind to the loaded dataset with the GUI. At this moment sample has list box as the UI. Binding of the UI is done by using Default View of the dataset. Just torevise every dataset has tables and every table has views. In this sample, we have onlyloaded one table i.e. Employees table so we are referring that with an index of zero.Just say all the five steps during interview and you will see the smile on the interviewer’sface and appointment letter in your hand.
(B) What are the various methods provided by the dataset object togenerate XML?