在创建我的程序时,我发现为包提供本地数据库将更可靠,而不是连接到每个实例的远程数据库。更新远程访问服务器
下面是我的想法如何做到这一点,但我希望它自动发生每个不同的主机,它发现,而不是选择每个成员,并按下按钮。这是我不知道如何实现的。
Imports System.Data.OleDb
Public Class Form1
Dim con as oledbconnection = new oledbconnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='.\localDB.accdb'")
Dim rem as oledbconnection = new oledbconnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='\\server\remote.accdb'")
dim da as new oledbdataadaptor
dim dt as new datatable
dim dt2 as new datatable
Dim Str as string
Dim cmd as new oledbcommand(str, con)
Private Sub Form1_load
con.open()
da.SelectCommand = New OleDbCommand("select distinct Host from Logs")
da.fill(dt)
con.close
Combobox1.datasource = dt
Combobox1.displaymember = "Host"
End Sub
Private Sub button1_click
con.open()
Dim cmd As New OleDbCommand("select * from local where [email protected];", con)
cmd.parameters.addwithvalue("@host", combobox1.text.tostring)
da.fill(dt2)
con.close()
rem.open()
Dim cmd1 As New OleDbCommand("update remote set [email protected] where [email protected];", con)
cmd1.parameters.addwithvalue("@col1", dt2.rows(0).item(1).tostring)
cmd1.parameters.addwithvalue("@ID", dt2.rows(0).item(0).tostring)
rem.close()
End Sub
End Class
任何想法的将不胜感激。 *作为说明,我知道JET提供了同步功能,但是数据库必须采用2007-10格式,所以ACE是唯一的选择。
我想你会发现这确实起作用。 http://stackoverflow.com/questions/19979758/access-update-with-visual-basic-sql?rq=1如果你想看看这里。 – Tad
我以我会这样做的方式纠正了您的代码。在答案中看到我的更新 – equisde
但您没有阅读或确认这个问题。我要求一种方法(如果有的话)自动更新从日志中提取的每条不同记录。你所做的一切都是用更多的行重写我的代码。 – Tad