.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

Explain the steps involved to populate dataset with data?

Posted By :Shashi Ray     Posted Date :December 07, 2009    Points :10   Category :.NET Framework 
Open connection.;
Initialize Adapter passing SQL and connection as parameter.;
Initialize Dataset.;
Call Fill method of the adapter passes dataset as the parameter.;
Close connection.;

You can also find related Interview Question to Explain the steps involved to populate dataset with data?  below: 

What are the steps involved to fill a dataset?

Dataset dsIndia=new Dataset();
DataAdapter daIndia=new DataAdapter ();
daIndia.Fill(dsIndia); (More...)

What is the difference between Data Reader & Dataset?

Data Reader is connected datasource, read only, forward only record set.

Dataset is disconnected datatsource resides in memory database that can store multiple tables, relations and constraints; (More...)

Explain about data provider?

ADO.NET has two primary parts in its architecture out of which one is data provider. It has its own set of objects and it consists of its own classes. Some of them are connection, parameter, data reader, command and data adapter. This provides access to data sources such as Oracle, SQL server, etc. (More...)

You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so?

Select the correct answer.

1. Use the Sort method on the DataTable object.
2. Use the DataSet object's Sort method.
3. Use a DataView object for each sort.
4. Create a DataTable for each sort, using the DataTable object's Copy method, and then Sort the result

Correct Answer is :
3. Use a DataView object for each sort. (More...)

Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

. Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
. A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
. A DataSet is designed to work without any continuing connection to the original data source.
. Data in a DataSet is bulk-loaded, rather than being loaded on demand.
. There's no concept of cursor types in a DataSet.
. DataSets have no current record pointer You can use For Each loops to move through the data.
. You can store many edits in a DataSet, and write them to the original data source in a single operation. (More...)

Is it possible to have tables in the dataset that are not bound to any data source?

Yes, I can create table object in code and add it to the dataset. (More...)

Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset. There are important differences between them.
o A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data from the various database tables into a single result table. In contrast, a dataset is a collection of one or more tables. The tables within a dataset are called data tables; specifically, they are DataTable objects. If a dataset contains data from multiple database tables, it will typically contain multiple DataTable objects. That is, each DataTable object typically corresponds to a single database table or view. In this way, a dataset can mimic the structure of the underlying database. A dataset usually also contains relationships. A relationship within a dataset is analogous to a foreign-key relationship in a database -that is, it associates rows of the tables with each other. For example, if a dataset contains a table about investors and another table about each investor's stock purchases, it could also contain a relationship connecting each row of the investor table with the corresponding rows of the purchase table. Because the dataset can hold multiple, separate tables and maintain information about relationships between them, it can hold much richer data structures than a recordset, including self-relating tables and tables with many-to-many relationships.
o In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method. In ADO.NET, rows are represented as collections, so you can loop through a table as you would through any collection, or access particular rows via ordinal or primary key index. DataRelation objects maintain information about master and detail records and provide a method that allows you to get records related to the one you are working with. For example, starting from the row of the Investor table for "Nate Sun," you can navigate to the set of rows of the Purchase table describing his purchases. A cursor is a database element that controls record navigation, the ability to update data, and the visibility of changes made to the database by other users. ADO.NET does not have an inherent cursor object, but instead includes data classes that provide the functionality of a traditional cursor. For example, the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object. For more information about cursor functionality, see Data Access Technologies.
o Minimized Open Connections: In ADO.NET you open connections only long enough to perform a database operation, such as a Select or Update. You can read rows into a dataset and then work with them without staying connected to the data source. In ADO the recordset can provide disconnected access, but ADO is designed primarily for connected access. There is one significant difference between disconnected processing in ADO and ADO.NET. In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source. The important difference is that in ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database - by optimizing for performance, performing data validation checks, or adding any other extra processing. Data adapters, data connections, data commands, and data readers are the components that make up a .NET Framework data provider. Microsoft and third-party providers can make available other .NET Framework data providers that can be integrated into Visual Studio.
o Sharing Data Between Applications. Transmitting an ADO.NET dataset between applications is much easier than transmitting an ADO disconnected recordset. To transmit an ADO disconnected recordset from one component to another, you use COM marshalling. To transmit data in ADO.NET, you use a dataset, which can transmit an XML stream.
o Richer data types.COM marshalling provides a limited set of data types - those defined by the COM standard. Because the transmission of datasets in ADO.NET is based on an XML format, there is no restriction on data types. Thus, the components sharing the dataset can use whatever rich set of data types they would ordinarily use.
o Performance. Transmitting a large ADO recordset or a large ADO.NET dataset can consume network resources; as the amount of data grows, the stress placed on the network also rises. Both ADO and ADO.NET let you minimize which data is transmitted. But ADO.NET offers another performance advantage, in that ADO.NET does not require data-type conversions. ADO, which requires COM marshalling to transmit records sets among components, does require that ADO data types be converted to COM data types.
o Penetrating Firewalls.A firewall can interfere with two components trying to transmit disconnected ADO recordsets. Remember, firewalls are typically configured to allow HTML text to pass, but to prevent system-level requests (such as COM marshalling) from passing. (More...)

How to fill DataSet with data?

To fill DataSet with data we have to use Fill() method of DataAdapter object.

Fill() has several overloads. But the simple one is
[CODE]Fill(DataSet, DataTable)[/CODE]
The first parameter will take the name of the dataset to be filled and the second parameter specifies the name of the DataTable in the DataSet which will contain the data. (More...)

Populate multiple controls from DB in a single function using a single DataSet

Step 1:
- Write the different queries for getting the data from the DB for different controls in a single string variable by separating them with semicolon.

Ex -
//Create the SQL query.
string selectQueryForControlPopulation =
Step 2:
- Create the DataAdapter, DataSet object. Execute the query and fill the DataSet object.

Ex -
//Create the Connection object.
OleDbConnection oConnection = new OleDbConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]);

//Create the Command object.
OleDbCommand oCommand = new OleDbCommand(selectQueryForControlPopulation , oConnection );

//Create the DataAdapter object and set its property.
OleDbDataAdapter oAdapter = new OleDbDataAdapter();
oAdapter .SelectCommand = oCommandPopulateOrganizations;

// Create a DataSet object.
DataSet oDataSet = new DataSet();

//Filling the DataSet object.
oAdapter .Fill(oDataSet);

(**) The DataSet object contain the result of different queries as different tables. We can access those table to fill our controls.

http://www.mindfiresolutions.com/Populate-multiple-controls-from-DB-in-a-single-function-using-a-single-DataSet-831.php (More...)

Explain Constraints Of Data Integrity?

i) A PRIMARY KEY constraint is a unique identifier for a row within a database table. Every table should have a primary key constraint to uniquely identify each row and only one primary key constraint can be created for each table. The primary key constraints are used to enforce entity integrity.

ii) A UNIQUE constraint enforces the uniqueness of the values in a set of columns, so no duplicate values are entered. The unique key constraints are used to enforce entity integrity as the primary key constraints.

iii) A FOREIGN KEY constraint prevents any actions that would destroy links between tables with the corresponding data values. A foreign key in one table points to a primary key in another table. Foreign keys prevent actions that would leave rows with foreign key values when there are no primary keys with that value. The foreign key constraints are used to enforce referential integrity.

iv) A CHECK constraint is used to limit the values that can be placed in a column. The check constraints are used to enforce domain integrity.

v) A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints. (More...)

On a routine monitoring of the data files and transaction log, you notice that the transaction log is extremely close to being full. What will happen if the log fills? What steps can you take to avoid running out of transaction log space?

If the transaction log fills, you are unable to modify the data in the database until the log is archived or expanded. To avoid a full transaction log, you can monitor the log space regularly, expand the log whenever necessary, set the log to grow automatically, and create an alert to notify you when the available log space falls below a specified level (alerts are not covered in this training kit). Scheduling or performing frequent transaction log dumps is the best way to reclaim available space in the transaction log.

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend