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
Write a Program of Changing String Order - C# Language  using System;   class Prog3_2  {       public static void Main(String [] args)    {     Console.Write(ar

I want a Panel for youtube views and facbook likes. I need a panel made that can increase facebook fanpage likes, and that will increase youtube video views. Youtube views an

Information Retrieval from Multi-Agent System with Data Mining in Cloud Computing Project Description: I have planned one research model on "Information Retrieval through Mul

I need .net expert help for Advance Project First let me start by saying that I have been writing code for almost 25 years. Therefore I am only looking for someone to aid advanc

What are benefits and Limitation of using Viewstate for state management The benefits of using Viewstate are as follows:- 1)    There is no server resources required because

recipe house Project Description: Web application with sql database Skills required are .NET, C# Programming, HTML, PHP, SQL

NopCommerce v3.10 - Content Page Creation, Product Import and Site Customization Project Description: I have an existing website with about 800 products and we could like to

Project Description: Take a CSV of Canadian street addresses. For every address, translate the address into a GPS coordinate. Use the GPS coordinate to test whether or not the a

What is the use of connection object? The connection objects are used to connect a data to the Command object. 1)An OleDbConnection object is used with the  OLE-DB provider

WDS and MDT Deployment Server Training Project Description: I'm seeking someone who can Teach/Train me with MDT and WDS server. This Can be online teaching courses. I will