Problem in inserting date to database using calender

Feb 21 2018 12:35 PM
Respected sir/Ma'am,
 
I am making a website in visual studio 2005 ,ASP.NET C# using oracle 11g client .
Normally the data is inserting to database but using calender it is niether showing error not inserting data to database.
 
Please Help
 
******************Source Code******************
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.OracleClient;
using System.Data.OleDb;
public partial class Regis : System.Web.UI.Page
{
//OleDbConnection conn = new OleDbConnection("Provider=MSDAORA;" + "DATA SOURCE = localhost:1521 / xe; USER ID = SYSTEM; password=system");
OracleConnection conn = new OracleConnection("DATA SOURCE=localhost:1521/xe;USER ID=SYSTEM;password=system");
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Calendar1.Visible = false;
}
try
{
conn.Open();
string stn = "select * from reg";
OracleDataAdapter oda = new OracleDataAdapter(stn, conn);
// OleDbDataAdapter oda = new OleDbDataAdapter(stn, conn);
DataTable dt = new DataTable();
oda.Fill(dt);
}
catch (Exception ex)
{
}
finally
{
conn.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
conn.Open();
string stn = "insert into reg(R_ID,R_NAME,r_date) values('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" +this. Calendar1.SelectedDate + "')";
OracleCommand cmd = new OracleCommand(stn, conn);
//OleDbCommand cmd = new OleDbCommand(stn, conn);
//OracleDataReader md;
//md = cmd.ExecuteReader();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{ }
finally
{
Response.Write("<script>alert('Data Inserted')</script>");
conn.Close();
TextBox1.Text = "";
TextBox2.Text = "";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
conn.Open();
string stn = "select * from reg";
OracleDataAdapter oda = new OracleDataAdapter(stn, conn);
//OleDbDataAdapter oda = new OleDbDataAdapter(stn, conn);
DataTable dt = new DataTable();
oda.Fill(dt);
GridView1.DataBind();
}
catch (Exception ex)
{
}
finally
{
conn.Close();
}
}
}
}
protected void Button5_Click(object sender, EventArgs e)
{
Response.Write("<script >");
Response.Write("window.close();");
Response.Write("</script>");
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
//protected void Calendar1_SelectionChanged(object sender, EventArgs e)
//{
// TextBox3.Text = Calendar1.SelectedDate.ToShortDateString();
// Calendar1.Visible = false;
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox3.Text = Calendar1.SelectedDate.ToShortDateString();
TextBox4.Text = Calendar1.SelectedDate.ToShortTimeString();
Calendar1.Visible = false;
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (Calendar1.Visible)
{
Calendar1.Visible = false;
}
else
{
Calendar1.Visible = true;
}
}
protected void calender1_DayRender(object sender, DayRenderEventArgs e)
{
Response.Write(e.Day.Date + "<br/>");
if (e.Day.IsOtherMonth || e.Day.IsWeekend)
{
e.Day.IsSelectable = false;
}
}

Attachment: regis.zip

Answers (2)