请问VB.NET中datagridview表里的数据怎样写入到数据库中
发布网友
发布时间:2022-04-10 13:41
我来回答
共1个回答
热心网友
时间:2022-04-10 15:11
Public Class datafrm
Dim conn As SQLite.SQLiteConnection
Dim cmd As SQLite.SQLiteCommand
Dim ap As SQLite.SQLiteDataAdapter
Dim mytable As New DataTable
Private Sub datafrm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
conn = New SQLite.SQLiteConnection("data source=InfoCenter.db")
cmd = New SQLite.SQLiteCommand("select * from leader", conn)
ap = New SQLite.SQLiteDataAdapter(cmd)
conn.Open()
ap.Fill(mytable)
DataGridView1.DataSource = mytable
End Sub
'更新操作
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sd As New SQLite.SQLiteCommandBuilder(ap)
ap.Update(mytable)
End Sub
End Class