C# ASP.NET ADO.NET JAVASCRIPT JQUERY AJAX SILVERLIGHT WPF
C# OOPS HTML&CSS DHTML ASP.NET ADO.NET JAVASCRIPT JQUERY AJAX SILVERLIGHT MVVM WPF SQL SERVER Photoshop Dreamweaver Flash Illustrator
Blog Archive
-
2012
(83)
- September(2)
-
August(81)
- Important WPF Classes and Namespaces
- Applications of WPF
- Programming With WPF
- Limitations of Silverlight and flash
- Silverlight Feature comparison with Flash Features
- How to Add XML File in Your Silverlight Project
- 3 Pixel Shader Effects in Silverlight
- Rotate Image in 3D direction using Silverlight
- First Application of Silverlight
- Silverlight 2.0
- How Install Ajax?
- Ajax Advantage
- JavaScript Loops
- Show a Military Clock and ordinary clock
- How To validate a Form in ASP. Net
- How to show Day of Week
- How to Swap a Image using JavaScript
- Special Character in JavaScript
- Prompt Box in JavaScript
- The use of data adapter.?
- The steps involved to fill a dataset?
- Dataset object in ADO .NET
- Handling Connection Events
- The SQLCONNECTION OBJECT
- Command Constructors
- The SQLCOMMAND OBJECT
- Gridview in ASP.NET
- Introduction Of Master Page
- Server Side State Management
- Query String In ASP.NET
- Cookies in ASP.NET
- State Management in ASP.NET
- Various types of application that we can develop i...
- Properties
- Inheritance ,Polymorphism
- Array,Indexer and Collections
- Control Statements
- Operators, types and variables in C#
- Fundamental of C#
- C# & other Programming Languages
- The WPF Designer
- C# DataTypes
- What is Ajax?
- Silverlight 1.0
- Confirm Box in JavaScript
- Component classes
- Life Cycle of ASP.NET
- The Basics of JQuery
- Jquery Blog Content
- Birth Of WPF
- .Net Frameworks Architecture
- History Of Ajax
- Why Silverlight?
- How to access a URL of parent page in ASP. net
- THE ADO.NET Architecture?
- Architecture of ASP.NET
- Introduction Of Ajax
- Ajax Blog Content
- Introduction of SilverLight
- Silverlight Blog Content
- Introduction to Javascript Blog
- Javascript Blog Content
- Introduction to Ado.Net blog
- Ado.Net Blog Content
- Introduction to C# Blog
- C# Blog Content
- Introduction to Asp.Net
- Asp.Net Blog Content
- Introduction to WPF
- WPF Blog Content
- WPF Interview Question
- Silverlight Interview Question
- Ajax Interview Question
- JQuery Interview Question
- Javascript Interview Question
- DHTML Interview Question
- Ado.Net Inetview Questions
- SQL Interview Questions
- HTML&CSS Interview Questions
- Asp.Net Interview Qusetions
- C# Interview Questions
The steps involved to fill a dataset?
The steps involved to fill a dataset?
There are following steps to fill a dataset:-
(i). Create a connection object.
(ii). Create an adapter by passing the string query and the connection object as
parameters.
{iii). Create a new object of dataset.
(iv). Call the Fill method of the adapter and pass the dataset object.
We can check that some changes have been made to dataset since it was loaded?
There are following way to check that some changes have been made to dataset since it was loaded:-
(i). GetChanges: gives the dataset that has changed
since newly loaded or since Accept changes has been executed.
{ii}. HasChanges: this returns a status that tells if any
changes have been made to the dataset since accept changes was executed.
How can we add/remove row’s in “DataTable” object of “DataSet”?
Using NewRow method we can add row's in a data table object of
dataset.Remove method of the DataRowCollection is used to remove a ‘DataRow’
object from ‘DataTable’.
RemoveAt method of the DataRowCollection is used to remove a ‘DataRow’ object
from ‘DataTable’ per the index specified in the DataTable.
The underlying database can be updated directly by passing SQL INSERT/UPDATE/ DELETE statements, or stored procedure calls, through to the managed provider. It
We can also be updated using a DataSet.
The steps are:
-
Create and fill the DataSet with one or more DataTables
-
Call DataRow.BeginEdit on a DataRow
-
Make changes to the row’s data
-
Call DataRow.EndEdit
-
Call SqlDataAdapter.Update to update the underlying database
-
Call DataSet.AcceptChanges (or DataTable.AcceptChanges orDataRow.AcceptChanges)
Example :-UPDATING THE DATABASE USING A DATASET
To update the database directly, we can use the SqlCommand object, which allows us to execute SQL INSERT, UPDATE, and DELETE statements against a database.
Using System; using System.Data; using System.Data.SqlClient; public class empdel { public static void Main() { SqlConnection con = new SqlConnection( @"server=(local)\computer;database=emp;trusted_connection=yes" ); string sql = "DELETE FROM emp WHERE emp_name = 'Ashok'"; SqlCommand cmd = new SqlCommand(sql, con); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); Console.WriteLine("{0} record(s) deleted.", i); } } |
To load multiple tables in a DataSet
DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter ("Emp", this.Connection); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.AddWithValue ("@EId", EId); da.TableMappings.Add ("Table", ds.xval.TableName); da.Fill (ds); |
ADO.NET Code showing Dataset storing multiple tables.
DataSet ds = new DataSet(); ds.Tables.Add(dt1); ds.Tables.Add(dt2); ds.Tables.Add(dt3); ds.Tables.Add(dt4); ds.Tables.Add(dt5); .................. ................. .................. ds.Tables.Add(dtn);; |