请问VB.NET中datagridview表里的数据怎样写入到数据库中
VB.NET中datagridview表里的数据怎样写入到数据库中,请给出实际操作代码,不要理论说说的道理,谢谢...
VB.NET中datagridview表里的数据怎样写入到数据库中,请给出实际操作代码,不要理论说说的道理,谢谢
展开
展开全部
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询