My application is in VS2008 coded in VB.Net
I have a DatagridView.I have a Save Button on my Form.Now my requirement is i want to Update the Data that is populated in Datagridview when i click on Save button.
I want to do it using Update Query.
below is my code.
DgvStudRecord is my DatagridView
I want to update only the Fourth Column in Datagrid.
Expand|Select|Wrap|Line Numbers
- Sub update()
- DBConnect()
- con = DBActions.DBConnect
- strsql = "Update AdmittedStudents set MobileNo='" DgvStudRecord.Item(4, DgvStudRecord.CurrentCell.RowIndex) "' where RegNo='" & 1 & "'"
- cmd = New SqlCommand(strsql, con)
- cmd.ExecuteNonQuery()
- MessageBox.Show("Record Updated", "Weekly Off", MessageBoxButtons.OK)
- End Sub
Please suggest at the earliest where im wrong.