Regarding updation in Datagrid-----Urgently
-
Iam new to VB.Net2005. In the Form Load Event Iam Displaying Data into Datagridviewand I have written a code for Double-click event which is going to disply the data in the relevent textboxes from datagridview. After Displaying I want to modify the Data and updating it into the Database. For this I have written the code as: ds.Tables("emp_details").Rows(n).Item(1) = txtsurname.Text ds.Tables("emp_details").Rows(n).Item(2) = txtname.Text ds.Tables("emp_details").Rows(n).Item(3) = txtdesg.Text ds.Tables("emp_details").Rows(n).Item(4) = txtplace.Text ds.Tables("emp_details").Rows(n).Item(5) = txteligamt.Text ds.Tables("emp_details").Rows(n).Item(6) = txtfno.Text ds.Tables("emp_details").Rows(n).Item(7) = txtyear.Text da.Update(ds.Tables("emp_details")) But Iam getting the error as : "Update requires a valid updatecommand when passed Datarow collection with modified rows". Please suggest me correct code for this updation urgently ThanX in advance
-
Iam new to VB.Net2005. In the Form Load Event Iam Displaying Data into Datagridviewand I have written a code for Double-click event which is going to disply the data in the relevent textboxes from datagridview. After Displaying I want to modify the Data and updating it into the Database. For this I have written the code as: ds.Tables("emp_details").Rows(n).Item(1) = txtsurname.Text ds.Tables("emp_details").Rows(n).Item(2) = txtname.Text ds.Tables("emp_details").Rows(n).Item(3) = txtdesg.Text ds.Tables("emp_details").Rows(n).Item(4) = txtplace.Text ds.Tables("emp_details").Rows(n).Item(5) = txteligamt.Text ds.Tables("emp_details").Rows(n).Item(6) = txtfno.Text ds.Tables("emp_details").Rows(n).Item(7) = txtyear.Text da.Update(ds.Tables("emp_details")) But Iam getting the error as : "Update requires a valid updatecommand when passed Datarow collection with modified rows". Please suggest me correct code for this updation urgently ThanX in advance
What is da.Update?
-
What is da.Update?
That is DataAdapter.Update
-
That is DataAdapter.Update
-
Iam new to VB.Net2005. In the Form Load Event Iam Displaying Data into Datagridviewand I have written a code for Double-click event which is going to disply the data in the relevent textboxes from datagridview. After Displaying I want to modify the Data and updating it into the Database. For this I have written the code as: ds.Tables("emp_details").Rows(n).Item(1) = txtsurname.Text ds.Tables("emp_details").Rows(n).Item(2) = txtname.Text ds.Tables("emp_details").Rows(n).Item(3) = txtdesg.Text ds.Tables("emp_details").Rows(n).Item(4) = txtplace.Text ds.Tables("emp_details").Rows(n).Item(5) = txteligamt.Text ds.Tables("emp_details").Rows(n).Item(6) = txtfno.Text ds.Tables("emp_details").Rows(n).Item(7) = txtyear.Text da.Update(ds.Tables("emp_details")) But Iam getting the error as : "Update requires a valid updatecommand when passed Datarow collection with modified rows". Please suggest me correct code for this updation urgently ThanX in advance
You're looking for the CommandBuilder class for the database you're using. If you have an Access database, then you'd be using the OleDbCommandBuilder[^]. If SQL Server, SqlCommandBuilder[^]. These classes take the Select command that you gave to your dataadapter and build the other three corresponding SQL commands, DELETE, INSERT, and UPDATE, for you. It will only work with single table Select commands though.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007