using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class frmAddEventCalender : System.Web.UI.Page { SqlConnection sqlConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RSIC"].ConnectionString); SqlCommand cmd = null; protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { Response.Redirect("login.aspx"); } else { } } protected void btnEnterDetails_Click(object sender, EventArgs e) { try { //string str1 = DateTime .no; //string[] dtSplit = str1.Split('-'); //string storedate = dtSplit[1] + "-" + dtSplit[0] + "-" + dtSplit[2]; sqlConn.Open(); cmd = new SqlCommand(); cmd.CommandText = " INSERT INTO [AddEventCalender] " + " ([EventHeader],[EventDetails] ,[EventDate]) " + " VALUES('" + txtAddEvent.Text + "','" + txtEventDetails.Text + "','" + txtEventDate.Value + "')"; cmd.Connection = sqlConn; cmd.CommandType = CommandType.Text; int entryStatus = cmd.ExecuteNonQuery(); sqlConn.Close(); if (entryStatus != 0) { Response.Write(""); EmptyField(); } else { Response.Write(""); } } catch (Exception ex) { Response.Write(""); } } void EmptyField() { txtAddEvent.Text = ""; txtEventDate.Value = ""; txtEventDetails.Text = ""; } }