berikut codingan nya.
Imports System.Data.SqlClient
Public Class Form2
Const connectionstring As String = "Data Source=TOP;Initial Catalog=latihan;Persist Security Info=True;User ID=atm; password=atm"
Private SQL As String = "select * from siswa"
Private con As New SqlConnection(connectionstring)
Private dt As New DataTable
Private adapter As New SqlDataAdapter(Sql, con)
Private commandbuilder As New SqlCommandBuilder(adapter)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
adapter.Fill(dt)
DataGridView1.DataSource = dt
End Sub
Private Sub DataGridView1_RowEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowEnter
adapter.Update(dt)
End Sub
Private Sub DataGridView1_RowLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowLeave
adapter.Update(dt)
End Sub
End Class
sekian cara update data di Datagridview dengan edit rows di vbnet. silahkan download project nya di sini http://www.mediafire.com/download/cw025fdq0hinp2e/Datagridview+update+edit+rows.rar
Perhatian: Yuk Baca Artikel bagus di Nurul Musthofa
ERROR KANG
ReplyDelete{"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."}
mantab bisa om!
ReplyDelete