Steps involved to fill a dataset, DOT NET Programming

What are the steps involved to fill a dataset ?

The sample code is shown below:

Private Sub LoadData()

Dim strConnectionString As String

strConnectionString = AppSettings.Item("ConnectionString") Dim objConn As New SqlConnection(strConnectionString) objConn.Open()

Dim objCommand As New SqlCommand("Select FirstName from

Employees")

objCommand.Connection = objConn

Dim objDataAdapter As New SqlDataAdapter() objDataAdapter.SelectCommand = objCommand Dim objDataSet As New DataSet

End Sub

In this type of questions interviewer is looking from the practical angle, that have you worked with dataset & datadapters. Let me try to explain the above code first and then we go to what steps must be told during the interview.

Dim objConn As New SqlConnection(strConnectionString)

objConn.Open()

The First step is to open the connection. Now again note the connection string is loaded from the config file.

Dim objCommand As New SqlCommand("Select FirstName from Employees") objCommand.Connection = objConn

The Second step is to create a command object with the appropriate SQL and set the connection object to this command

Dim objDataAdapter As New SqlDataAdapter()

objDataAdapter.SelectCommand = objCommand

The Third steps is to create an  Adapter object and pass the command object to the adapter object.

objDataAdapter.Fill(objDataSet)

The Fourth step is to load the dataset using the "Fill" method of the dataadapter.

lstData.DataSource = objDataSet.Tables(0).DefaultView

lstData.DisplayMember = "FirstName"

lstData.ValueMember = "FirstName"

The Fifth step is to bind to the loaded dataset with the GUI. At that moment the sample has a listbox as the UI. The Binding of the UI is completed by using the DefaultView of the dataset. Just to revise each dataset has tables and each table has views. In this sample we have only loaded one table that is Employees table so we are referring that with an index of zero.

Posted Date: 9/24/2012 2:46:32 AM | Location : United States







Related Discussions:- Steps involved to fill a dataset, Assignment Help, Ask Question on Steps involved to fill a dataset, Get Answer, Expert's Help, Steps involved to fill a dataset Discussions

Write discussion on Steps involved to fill a dataset
Your posts are moderated
Related Questions
I need Simple upgrades for ASP.NET site I have an existing web solution, we need a new page for creating additional features. The current website is done in C#.NET and ASP.NET.

sir, i just trapped in decryption.....wud u plz help me

finding greatest of n no''s in c#

In this assignment you will create a Windows application that mimic the ILDASM application. Your application should have at least the following features: 1. A multi-form applica

C# Programming 1. What is .Net Framework? 2. Write short notes on constructors and destructors. 3. Explain boxing and unboxing with examples. 4. What is a mixed mode a

What is XML? Extensible markup language (XML) is all about describing the data. Below is a XML which describes an invoice data. Shoes   12 10

What are the different types of replication supported by SQL SERVER? There are 3  types of replication supported by SQL SERVER which are shown below:- 1) Snapshot Replicati

What is a cloud? A cloud is a combination of hardware, storage, networks, services, and interfaces that helps in delivering computing as a service. It has generally three users

Explain Component diagrams Package: - The Package logically make group of element of a UML model. Component: - It is the actual physical module or implementation of

Project Description: Overview: Prepare Windows program that runs in the background and on start up on the client's computer that grabs CERTAIN data from a.SDF file (SQL Serve