please code solution and for rename row header I mean marking the color of the image file I attached Note : for notes I use visual studio 2010
Public Class Form1
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
dbConnection()
Dim indexID As Integer
x = DataGridView1.Rows.IndexOf(DataGridView1.CurrentRow)
indexID = Convert.ToInt32((DataGridView1.Rows(x).Cells(0).Value.ToString()))
sql = "UPDATE ITEM SET ITM= '" & txtFname.Text & "',ITC='" & txtLname.Text & "',QOH='" & cbGender.Text & "' WHERE ID=" & indexID & ""
cmd = New OleDbCommand(sql, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully Updated...", "Update")
conn.Close()
'btnReadDatabase_Click(sender, e);
retrieveALL()
End Sub
End Class
object reference not set Thanks roy
CodePudding user response:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
dbConnection()
sql = "UPDATE ITEM SET ITM= '" & txtFname.Text & "',ITC='" & txtLname.Text & "',QOH='" & cbGender.Text & "' WHERE ITC='" & txtLname.Text & "'"
cmd = New OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully Updated...", "Update")
con.Close()
PopulateDataGridView()
End Sub