Difference Between DataSet And DataTable In Asp.net

Here we will see some differences between dataset and datatable.

1) A DataTable is an in-memory representation of a single database table which has collection of rows and columns whereas a DataSet is an in-memory representation of a database-like structure which has collection of DataTables. Whenever you want to fetch data from database, it connects indirectly to the database and create a virtual database in local system and then disconnected from database.
OR
A DataTable is an in-memory representation of a single database table. You can think of it as having columns and rows in the same way. A dataset is an in-memory representation of a database-like structure. It can have one or more DataTables and define relations between them, key or any fields etc.

2) DataTable object is lighter than DataSet object since it contains data from single table whereas DataSet is heavier object that can contain data from multiple tables.

3) DataTable fetches only one TableRow at a time whereas DataSet can fetch multiple TableRows at a time

4) As DataTable is a single database table, so there is no DataRelation object in it whereas In DataSet, DataTable objects can be related to each other with DataRelation objects.

5) In DataTable, there is no Unique Constraint and Foreign Key Constraint objects available
But In DataSet, data integrity is enforced by using the Unique Constraint and Foreign Key Constraint objects.

6) In DataTable, DataSource cannot be serialized. But DataSet is serialized DataSource .That is why web services can always returns DataSet as the result but not the DataTables.

7) We can load a single database table into a DataTable and manipulate the data in memory. If we are going to fetch data from a single database table then DataTable is better choice. While DataSet on the other hand can define DataRelations – which define the relationship between DataTables, much like a foreign key relationship can be set up between tables in a database. DataSets, themselves DOES NOT contain any Data. DataSets contain DataTables (which is where any data actually resides), DataRelations, etc, but no data.

8) Dataset is a collection of tables, which is used in disconnected architecture. Generally to fill DataSet we use fill method of SqlDataAdapter. It can be used for manipulating the data remotely and finally updating the database with the modified data. This way it enables disconnected means of working with data. This improves performance in terms of reducing the number of times a database is accessed for data manipulations.

DataTable Example:
SqlDataAdapter adp = new SqlDataAdapter(“select * from SampleTable”, con);
DataTable dt = new DataTable();
adp.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();

DataSet Example:
SqlDataAdapter adp= new SqlDataAdapter(“select * from SampleTable”, con);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();

Original Source : http://www.webcodeexpert.com/2013/03/difference-between-dataset-and.html

Advertisements

Populate Dropdownlist With Time With Time Interval Dynamically In Asp.net.

Here we will see how to populate your dropdownlist with a time interval of 30 mins dynamically. For this we use TimeSpan class. We can also provide the time interval in hours, minutes and seconds.

Code is as follows: Continue reading Populate Dropdownlist With Time With Time Interval Dynamically In Asp.net.

Set Default Button For Enter Key Press In Asp.net

Here we will see how to set a button as the default button for enter key press. For this you have use Panel. For this example we have created a simple page where you will find two textbox and two button out of which the submit button has been set as the default button for the enter key. We have done this by setting the DefaultButton property of panel.

Code is as follows: Continue reading Set Default Button For Enter Key Press In Asp.net

Calling Asp.net C# Method (Web Method) Using JavaScript.

Here we will see how to avoid annoying post-backs on ASP.NET Web Pages. For this example we have created a simple page where you will be able to check the username availability. For this we need to take the advantage of PageMethod and to setup PageMethod we need instance of Script Manager on web page.

PageMethod an easier and faster approach for ASP.NET AJAX.PageMethod is a way through which we can expose server side page’s method in JavaScript. This brings so many opportunities, we can perform lots of operations without using slow and annoying post backs.

Code is as follows: Continue reading Calling Asp.net C# Method (Web Method) Using JavaScript.

Difference Between DDL, DML and DCL Commands.

DDL
Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:

CREATE – to create objects in the database
ALTER – alters the structure of the database
DROP – delete objects from the database
TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
COMMENT – add comments to the data dictionary
RENAME – rename an object
DML
Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:

SELECT – retrieve data from the a database
INSERT – insert data into a table
UPDATE – updates existing data within a table
DELETE – deletes all records from a table, the space for the records remain
MERGE – UPSERT operation (insert or update)
CALL – call a PL/SQL or Java subprogram
EXPLAIN PLAN – explain access path to data
LOCK TABLE – control concurrency
DCL
Data Control Language (DCL) statements. Some examples:

GRANT – gives user’s access privileges to database
REVOKE – withdraw access privileges given with the GRANT command

TCL
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

COMMIT – save work done
SAVEPOINT – identify a point in a transaction to which you can later roll back
ROLLBACK – restore database to original since the last COMMIT
SET TRANSACTION – Change transaction options like isolation level and what rollback segment to use

Performance Optimization in ASP.NET Web Sites

Asp.net Optimization And Performance.

Raj Aththanayake

Performance is an important aspect of a modern day web application development. Not only it makes sites seamless to use but also increase the scalability and future proof. In this article, we will look at various aspects of improving the performance of web applications. We would only concentrate on the browser/web server side performance as oppose to server/app server/database server performance optimizations.

Before we getting into detail, the first question is, do we really need optimized the web sites?

Amazon.com has performed a test on their web site, and when they slower the site in 100ms, the sales dropped by 1%. As you would imagine a company like Amazon, 1% is a huge lost

Google slower their Search Engine in 500ms, the traffic dropped by 20%

As you can see, it is a very important aspect of modern web site development.

This even becomes more important as nowadays most sites…

View original post 1,571 more words

Get Desired Html Color By Using System.Drawing.Color In Asp.net.

Here we will see how to get the html color in back end through the System.Drawing.Color Class.

From the bellow code you can get the Html Color by either its name or color code.

Code is as follows: Continue reading Get Desired Html Color By Using System.Drawing.Color In Asp.net.