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
Luke Baker
NA
20
21.8k
Cannot update datatable using datagridview
Apr 3 2012 12:24 PM
Im currently building a program to view and update data from a database using data grid views. I have text boxes and combo boxes to filter the data in the data grid view. This is achieved with the below code -
[code]
public void con(string command, DataGridView dgv, bool update)
{
string conStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\NTO.mdf;Integrated Security=True;User Instance=True";
SqlDataAdapter da = new SqlDataAdapter(command, conStr);
SqlCommandBuilder cBuilder = new SqlCommandBuilder(da);
DataTable dt = new DataTable();
da.Fill(dt);
BindingSource bSource = new BindingSource();
bSource.DataSource = dt;
dgv.DataSource = bSource;
}
[/code]
The problem being is getting to update the data when the data in the data grid view has been changed. I understand that you have to do dataAdapter.Update(datatable) but trying to do this when calling the con() method proves difficult??
ANY IDEAS??
Reply
Answers (
4
)
Programmatically sending email using a different Id
How to link update table with data grid view without command builder