TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Animesh Mishra
NA
19
9k
calculate remaining time from current date to selected date
Sep 2 2014 1:45 AM
calculate remaining time from current date to selected date and display the result on a label.In my design section i have 1 text box with a calender control and 1 button to submit the selected date in database and 1 label which shows the remaining days .
below is my code.
/*********************************************************/
using MySql.Data.MySqlClient;
using System.Windows.Forms;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
txtdate.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
string MyConnection2 = "datasource=localhost;port=***;username=***;password=***;DATABASE=ts";
string Query4 = "insert into ts1(DATESELECTED,CURRENTDATE) values('" + this.txtdate.Text + "',NOW());";
DateTime.Now.ToString("dd-MM-yyyy ");
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query4, MyConn2);
MySqlDataReader MyReader2;
MyConn2.Open();
MyReader2 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database.
MessageBox.Show("Save Data");
while (MyReader2.Read())
{
}
MyConn2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
please suggest ASAP
Reply
Answers (
4
)
help > string code button clear for visual basic
Listview