Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Hi all.
I am new in asp.net. I am making a website for my training project where i have insert date and save it to sql server database whenever the user selects a date. I want to know what should be the datatype of this date field when i am creating the table in sql server database .

Also how do i use the calender control to select the date and save the selected to the sqlserver database.

Please help me guys. I am stuck here.
Posted

Check this out:-

Create a calender and textbox in your design area.

And do this cs file:-

C#
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        TextBox1.Text = Convert.ToString(Calendar1.SelectedDate.ToShortDateString());
    }


On button_click simply save the textbox value in your sql database

Also in your sqlserver take the date_column field datatype as "date".

Happy coding ;)
 
Share this answer
 
Have you tried anything?

What about taking the calender and textbox, Then ondateselect property of calender set the textbox value = calender.selecteddate.

Lemme know if you face any further problem.

PS:You should do some reasearch on google.
 
Share this answer
 
Comments
Joy Banerjee 21-Apr-15 7:47am    
Yes. I created the sql table. There i kept the datatype as varchar. Because when I am passing values using the textbox from frontend, the values are having a format like "Day date, Month, Year". So it came to my mind that when i will try to retrieve the data with its respective date it will be easier for me to run a sql using 'like' operator.
Deepu S Nair 21-Apr-15 8:29am    
Don't post your comment as solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900