IntroductionToday, in this article let's play around with one of the interesting and most useful concept in Azure.Question: What is delete data from cloud database using Azure?In simple terms "It enables to delete data from cloud database and maintain with help of azure".Step 1: Create a cloud database named "Company"Step 2: With the help of manage URL navigate to specific server pageManage URL: etc6zpqnyc.database.windows.netStep 3: Company database showing up in the database server pageStep 4: Create an employee table. The design mode of employee table looks like thisStep 5: Insert some data into the tableStep 6: Open visual studio 2010 and create an "ASP.NET Web Forms Application", as in:Step 7: Add an EDMF item to the project.Step 8: Choose "Generate from database" and click the "Next" button, as in:Step 9: Add a new connection.Step 10: Give the necessary server details for the connection and click on ok.Step 11: The Connection is established; click the "Next" button.Step 12: Choose the required table and click the "Finish" button.Step 13: The created EDMF and design of data looks like this:Step 14: The complete code of default.aspx looks like this:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DeleteDataEFAzureApp._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title></title></head><body> <form id="form1" runat="server"> <center> <div> <table> <tr> <td colspan="2"> <asp:Label ID="Label1" runat="server" Text="Delete Data from Cloud Database with Azure" Font-Bold="true" Font-Size="Large" Font-Names="Verdana" ForeColor="Maroon"></asp:Label> </td> </tr> <tr> <td>
<asp:Label ID="Label6" runat="server" Text="Please Enter Id" Font-Size="Large" Font-Names="Verdana" Font-Italic="true"></asp:Label> </td>
<td> <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Button ID="Button2" runat="server" Text="Delete Data from Cloud Database" Font-Names="Verdana" Width="301px" BackColor="Orange" Font-Bold="True" OnClick="Button2_Click" /> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Label ID="Label5" runat="server" Font-Bold="true" Font-Names="Verdana" ForeColor="Maroon"></asp:Label> </td> </tr> </table> </div> </center> </form></body></html>Step 15: The complete code of default.aspx.cs looks like this:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace DeleteDataEFAzureApp{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { TextBox4.Focus(); } protected void Button2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TextBox4.Text)) { Label5.Text = "Please Enter Some Values"; Label5.ForeColor = System.Drawing.Color.Red; } else { CompanyEntities objCompany = new CompanyEntities(); Employee deleteQuery; var id = int.Parse(TextBox4.Text); deleteQuery = (from r in objCompany.Employees where r.ID == id select r).First(); objCompany.DeleteObject(deleteQuery); objCompany.SaveChanges(); Label5.Text = "Data Deleted Successfully";
Label5.ForeColor = System.Drawing.Color.Green; TextBox4.Text = string.Empty; } } }}
Step 16: The output of the application looks like this:Step 17: The output of table data before deleting the application looks like this:Step 18: Data entering output of the application looks like this:Step 19: Deleted data showing on the cloud output of the application looks like this:
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: