Imports System.Data.SqlClient
Public Class Form1
Dim da As SqlDataAdapter
Dim ds As DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strSql As String = "select * from member"
Dim strConn As String = "Data Source = . ; Initial Catalog = Northwind ; Integrated Security = true"
Dim conn As New SqlConnection(strConn)
da = New SqlDataAdapter(strSql, conn)
Dim cb As New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds, "member")
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
da.Update(ds, "member")
End Sub
End Class
留言列表