Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 05, 2012 05:10 AM by YunJiang
Apr 30, 2012 06:52 AM|LINK
I want to know how to insert a datetime value from asp.net using a calender control using C#. ? I have a Calender control and a button . When i click the button the date should be inserted into an sql server table which has a date column of the type datetype.
Apr 30, 2012 07:26 AM|LINK
Have u written stored procedure to perform Insert ? If yes post it here.
Apr 30, 2012 07:35 AM|LINK
No i havent . I know how to insert a textbox value using ADO.NET .Cant the same principle be applied to a calendar control?
Apr 30, 2012 07:43 AM|LINK
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "STOREDPROCEDURENAME"
cmd.Parameters.Add("@PARAMETERNAME1", SqlDbType.NVarChar).Value = Calendar1.SelectedDate.ToString("dd/MM/yyyy")
Hope this will help u a lot!!!!!!!!!!
Apr 30, 2012 08:32 AM|LINK
using (SqlCommand cmd = new SqlCommand("insert into TableName(Idate) values(@adate"),new SqlConnection("Your conn str here"))
Apr 30, 2012 09:01 AM|LINK
First of all i dont have much knowledge about stored procedures.Secondly, why cant we use the same principle used to insert a textbox value into a SQL database?
Apr 30, 2012 09:13 AM|LINK
Forget whatever i have asked . I will tell you my requirement . I have a registration page (as part of my college project (online library management system)) . In the registration page there is an option to enter the date of birth . I tried to use
the calender control . But now i realized that if i was born in june 1975 i should click all the way back from april 2012. Also the ADO code written with procedures is not in my league(Unless some one can make it simpler)
1) What are the othe alternatives for entering the date of birth in a registration form?
Apr 30, 2012 09:18 AM|LINK
better to use 3 dropdownlist one for day, month, year.....
may be this suitable for u r req.....
and about storing date in database just combine these 3 dropdownlist in watever dateformate u want.... and store in database...
Apr 30, 2012 09:26 AM|LINK
i thought about using three drop downs .
So should i combine these 3 values into a single value like(yyyy/mm/dd) and then insert it into the respective column?
Apr 30, 2012 10:15 AM|LINK
Another problem . Since the datatype of the date of birth is datetime in sql server and the three values combined is a string , i need to cast them into datetime type and i dont know how?|