Click here to Skip to main content
15,887,776 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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 
AnswerRe: Schedule for update date in C# Pin
Richard Deeming20-Jul-15 7:22
mveRichard Deeming20-Jul-15 7:22 
Why are you converting all of your dates to strings, and then parsing them back to dates? Just use them as dates:
C#
// Instead of:
dt = DateTime.ParseExact(rdr["Date"].ToString(), "dd/MM/yyyy", null);
// use:
dt = rdr.Field<DateTime>("Date");


// Instead of:
String cd = DateTime.Now.ToString("dd/MM/yyyy");
DateTime CD = DateTime.ParseExact(cd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
// use:
DateTime CD = DateTime.Today;


// Instead of:
List<String> dates = new List<String>();
...
Newdate = dt.AddDays(7);
DateTime Newdateonly = Newdate.Date;
String Ndate = Newdateonly.ToString("dd/MM/yyyy");
dates.Add(Ndate);

// use:
List<DateTime> dates = new List<DateTime>();
...
dates.Add(dt.AddDays(7).Date);


Having said that, you can replace all of your code with a single query:
C#
private static void Task()
{
    string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

    using (SqlConnection con = new SqlConnection(CS))
    using (SqlCommand cmd = new SqlCommand("UPDATE tblInsertDate SET [Date] = DateAdd(day, 7, [Date]) WHERE [Date] < @Today", con))
    {
        cmd.Parameters.AddWithValue("@Today", DateTime.Today);
        
        con.Open();
        cmd.ExecuteNonQuery();
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


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 
QuestionGridview Pin
simanungkalit14-Jul-15 22:35
simanungkalit14-Jul-15 22: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.