Steps involved to fill a dataset, DOT NET Programming

Assignment Help:

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.


Related Discussions:- Steps involved to fill a dataset

Explain keywords with example, Explain keywords with example. Keywords...

Explain keywords with example. Keywords are those words that are reserved to be used for an exact task. These words cannot be used as identifiers. You cannot use a keyword to

Creating a two player web based game, Required: An implementation of...

Required: An implementation of a two player game. Keep the game simple ROCK PAPER SCOSSORS A two player game, each player on a different browser instance.  (pro

Required c# programmer, The program is broke now but explains in text and p...

The program is broke now but explains in text and printscreens the specific things i have to do to implement new bookies new sports and change settings for looking for arbs on two

Explain some built-in functions of vbscript, Problem: (a) Explain the ...

Problem: (a) Explain the difference between these two lines of ASP codes: (b) The VBScript language includes some built-in functions which are often used in ASP co

What is cts and cls, What is CTS and CLS? => CLS stands for common lang...

What is CTS and CLS? => CLS stands for common language specification where as CTS stands for common type system. => CLS : cls is a standard for .net . cls is small set of sp

Web page parsed-manipulated and scraped, I have a page that I require a few...

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

Develope a microblogging and bookmarking site, General Overview A number...

General Overview A number of organisations are using micro-blogging as a cost-effective way of communicating with customers, building online communities and releasing informatio

Design patterns, What are design patterns? The Design patterns are recu...

What are design patterns? The Design patterns are recurring solution to the recurring problems in the software architecture. There are 3 basic classification of patterns Behavi

Flexible in rapidly moving from project to project, This is a whole time co...

This is a whole time contractual role working for a sports advisory service. We are data insights consultancy specializing in sports. We consult to a number of sporting organizatio

In what order global.asax are triggered?, They are triggered in the followi...

They are triggered in the following order as shown below: Application_BeginRequest Application_AuthenticateRequest Application_AuthorizeRequest Application_ResolveReque

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd