How do i Update data through a datagridview
Hi,
I have a data grid that gets data from one table in the database. I want to allow users to be able to update,add,or delete records via datadridview and update the changes to the database.How do i do that.
Here is my code that popualte the grid with data.
Private Sub PopulateGrid()
Dim ObjConn As New SqlConnection("server=(local);database=NHIF;Integr ated security=true")
Dim objDataAdapter As New SqlDataAdapter("select * from currentID", ObjConn)
'Try
objDataAdapter.SelectCommand = New SqlCommand
objDataAdapter.SelectCommand.Connection = ObjConn
objDataAdapter.SelectCommand.CommandText = "select DFname,DLname,Gender,MembershipNo,IssuedDate,Typeo fCard,BirthDate from currentID where CHECKNO='" & Trim(txtCheckNo.Text) & "'"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
ObjConn.Open()
objDataAdapter.Fill(objDataset, "currentID")
ObjConn.Close()
CURRENTIDDataGridView.DataSource = objDataset
CURRENTIDDataGridView.DataMember = "currentID"
objDataAdapter = Nothing
ObjConn = Nothing
End Sub
|