Professional Documents
Culture Documents
cmd.Parameters.AddWithValue("@Age", txtAge.Text);
cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lblMsg.Text = "Successfully Inserted";
txtName.Text = "";
txtSex.Text = "";
txtAge.Text = "";
txtAddress.Text = "";
}
catch (Exception ex)
{
//lblMsg.Text = "Not Successfully Inserted";
lblMsg.Text = ex.ToString();
}
}
}
}
Code Behind for Select, Update and Delete Data from DB
Presentation Layer
<table style=" font-family:Times New Roman; font-size:medium; font-weight:bolder">
<tr><td>ID</td><td>
<asp:TextBox ID="txtID" runat="server"></asp:TextBox></td></tr>
<tr><td>Name</td><td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox></td></tr>
<tr><td>Sex</td><td>
<asp:TextBox ID="txtSex" runat="server"></asp:TextBox></td></tr>
<tr><td>Age</td><td>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox></td></tr>
<tr><td>Address</td><td>
<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox></td></tr>
<tr><td></td><td>
<asp:Button ID="Select" runat="server" Text="Select" onclick="Select_Click" />
<asp:Button ID="Update" runat="server" Text="Update" onclick="Button1_Click" />
<asp:Button ID="Delete" runat="server" Text="Delete" onclick="Delete_Click" />
<asp:Label ID="lblMsg" runat="server" ForeColor="Red" ></asp:Label>
</td></tr>
</table>
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Onrtire
{
public partial class Update_Select : System.Web.UI.Page
{
string str =
ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
}
catch (Exception ex)
{
//lblMsg.Text = "Not Successfully Deleted";
lblMsg.Text = ex.ToString();
}