Click here to Skip to main content
15,913,939 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: query Pin
Richard Deeming22-Jul-15 1:42
mveRichard Deeming22-Jul-15 1:42 
GeneralRe: query Pin
Herman<T>.Instance22-Jul-15 22:42
Herman<T>.Instance22-Jul-15 22:42 
QuestionDevExpress ASpx Gridview Row Selection on keyboard Arrow key Pin
hemant kolekar20-Jul-15 19:33
hemant kolekar20-Jul-15 19:33 
AnswerRe: DevExpress ASpx Gridview Row Selection on keyboard Arrow key Pin
Wendelius20-Jul-15 19:43
mentorWendelius20-Jul-15 19:43 
QuestionCSRF question Pin
Stephen Holdorf20-Jul-15 10:31
Stephen Holdorf20-Jul-15 10:31 
AnswerRe: CSRF question Pin
Anil Vaghasiya20-Jul-15 19:37
professionalAnil Vaghasiya20-Jul-15 19:37 
AnswerRe: CSRF question Pin
Richard Deeming21-Jul-15 1:37
mveRichard Deeming21-Jul-15 1:37 
QuestionSchedule for update date in C# Pin
Member 1173518720-Jul-15 3:19
Member 1173518720-Jul-15 3:19 
I want to make one schedule in global.asax page that update date in database if current date is greater then database date. this schedule is run after every 24 hours. I have performed one task for it.
C#
private static void Task()
{
      String CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
      using (SqlConnection con = new SqlConnection(CS))
      {
        con.Open();
        DateTime Newdate;
        DateTime dt;
        SqlCommand cmd1 = new SqlCommand("select Date from tblInsertDate", con);
        cmd1.ExecuteNonQuery();
        List<String> dates = new List<String>();
        using (SqlDataReader rdr = cmd1.ExecuteReader())
        {
           while (rdr.Read())
           {
              dt = DateTime.ParseExact(rdr["Date"].ToString(), "dd/MM/yyyy", null);
              String cd = DateTime.Now.ToString("dd/MM/yyyy");
                        DateTime CD = DateTime.ParseExact(cd, "dd/MM/yyyy", CultureInfo.InvariantCulture);

              int result = DateTime.Compare(dt, CD);
              
              if (result < 0)
              {
                 Newdate = dt.AddDays(7);
                 DateTime Newdateonly = Newdate.Date;
                 String Ndate = Newdateonly.ToString("dd/MM/yyyy");
                 dates.Add(Ndate);
                 break;
              }
           }
        }
        foreach (String dataList in dates)
        {
           SqlCommand cmd2 = new SqlCommand("update tblInsertDate set Date=@Newdate where Date=@whereDate", con);
                    cmd2.Parameters.AddWithValue("@Newdate", dataList);
                                      cmd2.Parameters.AddWithValue("@whereDate",dt);
                    cmd2.ExecuteNonQuery();
                }
            }
}


all the value of database table is changed. I just want to update date row by row if current date is grater then databse date.

So I have to put one where condition in foreach loop but how to put where condition?

if i try to write

SQL
SqlCommand cmd2 = new SqlCommand("update tblInsertDate set Date=@Newdate where Date=@whereDate", con);
                    cmd2.Parameters.AddWithValue("@Newdate", dataList);
                    cmd2.Parameters.AddWithValue("@whereDate",dt);


then "dt" is not use as local variable.
AnswerRe: Schedule for update date in C# Pin
Richard Deeming20-Jul-15 7:22
mveRichard Deeming20-Jul-15 7:22 
QuestionDeployed website Error Pin
Stephen Holdorf17-Jul-15 7:54
Stephen Holdorf17-Jul-15 7:54 
AnswerRe: Deployed website Error Pin
Stephen Holdorf17-Jul-15 8:09
Stephen Holdorf17-Jul-15 8:09 
GeneralRe: Deployed website Error Pin
Stephen Holdorf20-Jul-15 10:07
Stephen Holdorf20-Jul-15 10:07 
Questiondid't got solution Pin
Rahul Singh Baghel16-Jul-15 21:46
professionalRahul Singh Baghel16-Jul-15 21:46 
AnswerRe: did't got solution Pin
User 418025417-Jul-15 2:58
User 418025417-Jul-15 2:58 
QuestionHow to compare the values of a particular column in an excel sheet Pin
Member 1184147115-Jul-15 23:57
Member 1184147115-Jul-15 23:57 
QuestionRe: How to compare the values of a particular column in an excel sheet Pin
Richard MacCutchan16-Jul-15 0:14
mveRichard MacCutchan16-Jul-15 0:14 
Questionthirdparty cookies Pin
SantoshKuamr15-Jul-15 22:32
SantoshKuamr15-Jul-15 22:32 
AnswerRe: thirdparty cookies Pin
Wombaticus15-Jul-15 23:11
Wombaticus15-Jul-15 23:11 
GeneralRe: thirdparty cookies Pin
SantoshKuamr16-Jul-15 0:18
SantoshKuamr16-Jul-15 0:18 
AnswerRe: thirdparty cookies Pin
F-ES Sitecore16-Jul-15 0:17
professionalF-ES Sitecore16-Jul-15 0:17 
GeneralRe: thirdparty cookies Pin
SantoshKuamr16-Jul-15 0:27
SantoshKuamr16-Jul-15 0:27 
GeneralRe: thirdparty cookies Pin
Richard MacCutchan16-Jul-15 1:47
mveRichard MacCutchan16-Jul-15 1:47 
SuggestionRe: thirdparty cookies Pin
The Tigerman20-Jul-15 10:31
The Tigerman20-Jul-15 10:31 
Questionhow to insert data in table with foreign key Pin
Praveen Kandari15-Jul-15 19:22
Praveen Kandari15-Jul-15 19:22 
AnswerRe: how to insert data in table with foreign key Pin
User 418025417-Jul-15 9:35
User 418025417-Jul-15 9:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.