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
prateek sharma
NA
6
468
code for audit history of database using update button in DG
May 8 2018 12:43 PM
can any one give me an example for audit history of database using update button in DG.
i.e.user should know who updated the 1st Row & 50th Row updated by other user in Datagridview.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "Submit")
{
using (OleDbConnection con1 = new OleDbConnection(con))
{
con1.Open();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con1;
string query1 = ("Update Reports set ID = @id,Comments = @comments,marks = @marks,Reviewer = '" + Environment.UserName + "',ReviewerDate = Now Where(ID = @id)");
cmd.Parameters.AddWithValue("@id", dataGridView1.Rows[i].Cells[0].Value);
cmd.Parameters.AddWithValue("@comments", dataGridView1.Rows[i].Cells[5].Value);
cmd.Parameters.AddWithValue("@marks", dataGridView1.Rows[i].Cells[6].Value);
cmd.CommandText = query1;
cmd.ExecuteNonQuery();
}
MessageBox.Show("Comments Submitted", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
code is working but Reviewer & Revieweddate is updating in whole datagridview rows
can anyone help?
Reply
Answers (
0
)
why using static class in C#
About visual studio 2017 issues?