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
r_keya
NA
9
0
Updating database from an editable datagrid
Jul 13 2004 12:41 AM
I am trying to use an editable datagrid to update data. When I try to debug it, the error is that it cannot find the ds and the da in private void btnChange_Click which is at the bottom of my code. Now I understand that these both are seperate private buttons with seperate event handlers. How do you then actually update the changed data? I read the MSDN site and they do the same thing. Here is my code: private void btnSubmitChange_Click(object sender, System.EventArgs e) { try { OleDbConnection conn = new OleDbConnection(ConnectionString); conn.Open();//conn.CreateCommand(); if(lstBxSelectData.SelectedItem.ToString()=="Tbl_Questions") { string getData = "SELECT * FROM Tbl_Questions"; OleDbDataAdapter da = new OleDbDataAdapter(getData,conn); DataSet ds = new DataSet(); da.Fill(ds); dtGrdData.SetDataBinding(ds,"Tbl_Questions"); ds.Tables["Tbl_Questions"].DefaultView.AllowEdit= true; ds.Tables["Tbl_Questions"].DefaultView.AllowDelete = true; } catch(Exception ex) { MessageBox.Show(ex.Message); } } private void btnChange_Click(object sender, System.EventArgs e) { OleDbCommandBuilder bd = new OleDbCommandBuilder(da); dtGrdData.Update(ds,"Tbl_Questions"); }
Reply
Answers (
3
)
How can I create an icon editor of size 32 * 32
How to call aother form though a btn_click event