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
CHAITANYA KIRAN KASANI
NA
335
133.2k
how To Update The DataGridview Data In DataBase In Winforms Using C#..?
Sep 28 2012 2:27 PM
Here Is My Code..
With this In Datagridview Only The First Modified Record Only Updating..Remaining Records are not updating. But I need All The Modified Records Should Be Update
pls help me.
private void btnUpdate(object sender, EventArgs e)
{
using (OleDbConnection connect = new OleDbConnection(connectionString))
{
using (OleDbCommand command = new OleDbCommand())
{
command.Connection = connect;
command.CommandText = "update customer set Name1=@name,Address=@address where Name1=@name";
command.Parameters.Add(new OleDbParameter("name", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("address", OleDbType.VarChar));
connect.Open();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
command.Parameters["name"].Value = row.Cells[0].Value;
command.Parameters["address"].Value = row.Cells[1].Value;
command.ExecuteNonQuery();
}
}
}
}
}
Reply
Answers (
2
)
struggle at making time table for school
how to use streamwriter/streamreader?