ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication
     

 
Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > ADO.NET
 

ASP.NET Tutorial - ADO.NET

                                                                                                             Page 12 of 14
 

Deleting Database Records

A data from a database is deleted by using the SQL Delete statement. The syntax for a Delete statement is as follows: -

If, for example, you want to delete all the rows from a table named Books where the bookName column has the value ASP.NET; the following statement would be used.

For the use of DELETE command follow these steps: -

1.Create and open a database connection.

2.Create a database command that represents the SQL Delete statement to execute.

3.Execute the command by calling the ExecuteNonQuery () method.

Look at the following example for executing DELETE command: -

 

Record Deleted from the table Books!

The output of this example is shown below:

 

The first line in the above example imports the necessary namespace to work with SQL Server.

Next, a connection to the SQL Server running on the local machine is initialized.

The SqlCommand class is initialized with two parameters: a SQL Delete statement and an instance of the SqlConnection class. Next, the connection is opened, the command is executed by calling ExecuteNonQuery (), and the connection is closed.

Next example shows how the same task can be accomplished in Microsoft Access database table named Books using the System.Data.OleDb namespace.

 

The output is shown as below:-

The first line in above example imports the necessary namespace to work with MS Access.

Next, a connection to the MS ACCESS running on the local machine is initialized.

The OleDbCommand class is initialized with two parameters: a SQL Delete statement and an instance of the OleDbConnection class.

Next, the connection is opened, the command is executed by calling ExecuteNonQuery (), and the connection is closed.

Important: - You must use Delete From rather than just Delete when working with a Microsoft Access database.

Parametric Delete

Practically we use Parametric Delete in the form of a web i.e. the parameters are passed from outside. The following example demonstrates it: -

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2015. All Rights Reserved.