Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
i have two date time picker named as follows;
dt_startweek and dt_endweek as two datetimepicker.
 

when i click the dt_startweek picker 21stdate in the dt_endweek picker five days 26th date to be displayed in the dt_endweek.
 
for that code as follows;
 
        private void dt_startweek_ValueChanged(object sender, EventArgs e)
        {
                DateTime dt = dt_startweek.Value;
                dt=dt.AddDays(5.0);
                dt_endweek.Value = dt;
                DateTime startdate = dt_startweek.Value;
                DateTime enddate = dt_endweek.Value;
              }
the above code is working fine no problem.
 

then i have one button called load when i click the load button that datepicker date 5 days to be saved in the data base.
 
for that saving the date into the database.how can i write code to save in the database.
 
help me.
 
Date base design as follows;
 
Fac_sch_date Date time (Data type)
 
output i want in the table as follows;
 
21/1/2013
22/1/2013
23/1/2013
24/1/2013
25/1/2013
26/1/2013
 

the above date to be saved in the data base when i click the load button.
 
what date i choose in the dt_startweek that date to be saved in the database.
 
please help me.
Posted 29-Jan-13 3:12am
Edited 29-Jan-13 3:16am
CHill6057.4K
v2
Comments
kshitij_CodeMaster at 29-Jan-13 9:27am
   
Dnt forget to say thanx who help u buddy.. its easy to copy n paste soln which u got frm smeone else...
Member 8054539 at 29-Jan-13 11:29am
   
ok thanks.how to save the date time picker date in database when i click the button.
 
please help me.
Rgds & thanks
narasiman

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

why not use the loop, when you want to do event Insert into database,
like this :
protected void Button1_Click(object sender, EventArgs e)
        {
            var dtime = dt_startweek.Value;
            var data = new ArrayList();
            for (var i = 0; i < 6; i++)
            {
                var xx = dtime.AddDays(i);
                data.Add(xx);
                // do for insert into database in here,can too..
            }
// OR
//Your first capacity in each variable, then enter one of the database into your
            var x1 = data[0];// date 21 from arraylist index [0]
            var x2 = data[1];// date 22
            var x3 = data[2];// date 23
            var x4 = data[3];// date 24
            var x5 = data[4];// date 25
            var x6 = data[5];// date 26

  // OR Like This

            var d1 = dtime;
            var d2 = dtime.AddDays(1);
            var d3 = dtime.AddDays(2);
            var d4 = dtime.AddDays(3);
            var d5 = dtime.AddDays(4);
            var d6 = dtime.AddDays(5);
 
        }
 
This parable is only sample code it .. just as a prefix to pave the way forward her your logic, associated with your coding
  Permalink  

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

  Print Answers RSS
0 Maciej Los 325
1 OriginalGriff 278
2 Nguyen.H.H.Dang 230
3 Peter Leow 195
4 arvind mepani 187


Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid