【发布时间】:2013-11-06 15:20:53
【问题描述】:
我已经搜索了这个解决方案并找到了非常接近的答案,但无法解决我需要的问题。我有一个使用 Access 表中的数据填充 datagridview 的表单。填充后,我需要将该信息附加到 sql server 中的表中。请问最好的方法是什么?感谢您的帮助
这是我的代码;
'connect to access
Dim myDBconn As New OleDbConnection("connection details here")
' SQL Statement
Dim sql As String
sql = "SELECT * FROM tblCustomerUpdates"
Dim adapter As New OleDbDataAdapter(sql, myDBconn)
' Gets the records from Access table and fills adapter
Dim dt1 As New DataTable("CustomerDetails")
adapter.Fill(dt1)
Dim sql1 As String
sql1 = "SELECT * FROM tblCustomerDetails"
Dim adapter1 As New OleDbDataAdapter(sql1, myDBconn)
Dim cmd1 As New OleDbCommand(sql1, myDBconn)
myDBconn.Open()
Dim myreader As OleDbDataReader = cmd1.ExecuteReader
myreader.Read()
' DataSource for the DataGridView
DataGridView2.DataSource = dt1
'now need to grab data from the datagridview or adapter and append rows to a table in sql server?
【问题讨论】:
标签: sql-server vb.net datagridview