Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to update data in vb.net, update code in vb.net
Posted
Comments
Sergey Alexandrovich Kryukov 1-Nov-13 2:26am    
The question as is makes no sense at all. It depends on what you do or want to do and many other factors.
Something tells me that you don't understand your question yourself, but, if I'm wrong, I'll gladly see your explanations.
—SA
fkassaie 3-Nov-13 9:46am    
i tnink you can use datagridview to update.

1 solution

Private Function GetActID()
'Action Id Fetch
Dim objReader As SqlDataReader
cmd.CommandText = "select ActId,ActCode from Hrm_ActionMst where ActCode='" & actCode & "'"
cmd = New SqlCommand(cmd.CommandText, conn1)
objReader = cmd.ExecuteReader
While objReader.Read
If actCode = objReader.GetValue(1) Then
Dim acid As Integer = objReader.GetValue(0)
objReader.Close()
Return acid
End If
End While
objReader.Close()
Return False
End Function
'----------------------------------------------------------------------

Private Sub BtnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpdate.Click
If txtcode.Text = "" Then
MsgBox("Enter Action Code !.", MsgBoxStyle.Exclamation, "Error")
txtcode.Focus()
Return
ElseIf txtdesc.Text = "" Then
MsgBox("Enter Action Description !.", MsgBoxStyle.Exclamation, "Error")
txtdesc.Focus()
Return
Else
Conn1.Open()
actID = GetActID()
Cmd.CommandText = "update Hrm_ActionMst set ActCode='" & txtcode.Text & "',CodeDescription='" & txtdesc.Text & "' where ActId='" & actID & "' "
Cmd = New SqlCommand(Cmd.CommandText, Conn1)
Cmd.ExecuteNonQuery()
MsgBox("Action Update Successfully", MsgBoxStyle.MsgBoxRight)
Conn1.Close()
End If
End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900