TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Muhammad Ali
NA
26
2.2k
I want to update the leftdays, Row by Row .not all at once.
Feb 5 2017 12:42 AM
I want to Update the Leftdays Column Row by Row but the Statement which i am using for Update .its updates the whole Column with same value .. as datareader loop calculates the different value while looping ... how i can make work properly ..please comment the Code ..
private void button3_Click(object sender, EventArgs e)
{
myconnection.Open();
displayData();
string selectSql = "select * from employTable2";
SqlCommand com = new SqlCommand(selectSql, myconnection);
using (SqlDataReader read = com.ExecuteReader())
{
while (read.Read())
{
string first1 = read["salarydate"].ToString();
string Second1 = read["expiredate"].ToString();
TimeSpan t1 = Convert.ToDateTime(Second1) - DateTime.Now;
int daysleft = t1.Days;
SqlConnection myconnection1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=c:\documents and settings\muhammad\my documents\visual studio 2010\Projects\ProjectClock\ProjectClock\ClockDB.mdf;Integrated Security=True;User Instance=True;");
myconnection1.Open();
SqlCommand cmd1 = new SqlCommand("UPDATE employTable2 SET daysleft='" + daysleft.ToString() + "'", myconnection1);
cmd1.ExecuteNonQuery();
myconnection1.Close();
MessageBox.Show(t1.Days +"", "Days Left");
}
myconnection.Close();
}
}
Reply
Answers (
13
)
Asp.net MVC . How to display name instead of ID in view page
Losing the data after post backing the page in jquery