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 want Text/Image printing Counter Project Description: Need your help in our C# programming project. We need to pass this project in two weeks starting from now to pass our

How can you use Hidden frames to cache client data? This technique is implemented by developing a Hidden frame in page which will have your data to be cached. T cols="100

Give a brief introduction of Windows Azure operating system. The Windows Azure operating system is used for running cloud services on the Windows Azure platform, as it includes

Need Experienced Outlook (Microsoft Office) developer Your required skills: (1) A developer at heart, one that knows how to prepare modular, well-designed and clean code, (2) va

wiConstellation WEB site Project Description: Creation of a dynamic corporate WEB site with administration panel, requirement collaboration, product definition, Q&A, user man

We have a VB.NET application to organize the edition and creation of dynamic PDF forms (fishing trip logsheet). The fishing vessel parameters are entered once for good in this VB.N

.NET aplication with vBulletin paid subscribtion Project Description: I have an application in .net it's a simple client i have sheltered with net seal license system for aut

What is the relationship between a class and an object? A class acts as a blue-print that explains the properties, states, and behaviors that are common to a number of objects.

I need deatch-bycahpca API tutorial Please teach me how to use deatch-bycahpa API Skills required: Visual Basic, C# Programming

I have a page that I require a few pieces of data to be pulled out of. The page is such that it needs interaction; there is a little bit of data entry to get the needed data, and t