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
Carlos Sanchez
NA
264
0
UpDate a Table
Jan 25 2005 4:50 PM
How can I retrieve data from a Table in a SqlServer, populate a DataGrid, modify the data in the DataGrid and UpDate the Data of the table? I tried this: MyDataAdapter = new SqlDataAdapter("SELECT * FROM MyTable", MyConnection); //Public DataAdapter SqlCommand MyUpDateCommand = new SqlCommand("UPDATE MyTable SET Column1 = @Column1, Column2 = @Column2", MyConnection); MyCommand.Parameters.Add("@Column1",System.Data.SqlDbType.Bit, 1, "Column1"); MyCommand.Parameters.Add("@Column2",System.Data.SqlDbType.VarChar, 50, "Column2"); MyDataAdapter.UpdateCommand=MyUpDateCommand; MyDataSet = new DataSet(); //Public DataSet MyDataAdapter.Fill(MyDataSet, "MyTable"); MyDataGrid.SetDataBinding(MyDataSet, "MyTable");//Also I tried MyDataGrid.DataSource = MyDataSet.Tables["MyTable"]; //Method of de Save Button SaveButton_Click(object sender, System.EventArgs e) { MyDataAdapter.Update(MyDataSet, "MyTable"); } The above it doesn't work. What am I missing? Could Any1 help me? Thanx in advance.
Reply
Answers (
6
)
How To Insert RTF Document to Access Database
Data Grid Update