MS Access 和 SQL Server 2008 帮助

发布于 2024-09-14 00:28:19 字数 362 浏览 3 评论 0原文

我需要有人为我指明正确的方向,我有一个由 HP 设备更新的 MS Access DB,我必须将其与 SQL Server 2008 同步。

我有一些想法,我想知道该怎么做你想一想:

  1. 是否有类似访问触发器之类的东西?如果可以的话我可以与 SQL Server 通信吗?
  2. 有没有办法使用 VBA 以便访问告诉我的 VBA 宏或其他内容来在 SQL Server 上进行更新?
  3. 有没有一种简单的方法可以从 VB 6 连接到 SQL Server 2008?
  4. 使用在后台运行的脚本并在 X 分钟或秒内检查数据库。

任何其他想法或建议都非常受欢迎。

谢谢,对英语总是感到抱歉。

I need somebody to point me to the right direction, I have a MS Access DB that is updated by HP devices, and I have to sync it with the SQL Server 2008.

I have a few Ideas, and I would like to know what do you think about this:

  1. Is there anything like triggers on access? if so can I comunicate with a SQL Server?
  2. Is there any way to use VBA so access tell my VBA macro or whatever to make an update on SQL Server?
  3. Is there a simple way to connect from VB 6 to SQL Server 2008?
  4. Using a script that run at background and check DB at X minutes or seconds.

Any other ideas or suggestions are very welcome.

Thanks and like always sorry for the english.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

〆一缕阳光ご 2024-09-21 00:28:19

只是为了在 adopilot 的答案中添加几点:

1)Access 2010 确实有触发器和存储过程,但我认为它们更多的是关于本机访问/jet 表,而不是链接的 SQL 表。

2& 3) 如果您想将 VB6 或 VBA 连接到 SQL 服务器,则执行此操作的技术称为 ADO,例如这里是一些打开连接并运行 SQL 语句的代码

Dim dbCon as NEW ADODB.Connection
dbCon.ConnectionString = strSQL_con_string
dbCon.Provider = "sqloledb"
dbCon.Open

dbCon.Execute “UPDATE tblFoo SET bar=5 WHERE Foo=1”

dbCon.Close

4) 您可以使用计时器在客户端执行此操作/wait event in VB6/Access or do it server side with a SQL job,由于提供的信息有限,不确定哪一个最适合您的情况

Just to add a few points to adopilot’s answer

1) Access 2010 does have triggers and stored procedures but they are more about native access/jet tables as opposed to linked SQL tables I believe.

2 & 3) If you want to connect VB6 or VBA to an SQL server then the technology to do that is called ADO for example here is some code to open a connection and run a SQL statement

Dim dbCon as NEW ADODB.Connection
dbCon.ConnectionString = strSQL_con_string
dbCon.Provider = "sqloledb"
dbCon.Open

dbCon.Execute “UPDATE tblFoo SET bar=5 WHERE Foo=1”

dbCon.Close

4) You can either do this client side with a timer/wait event in VB6/Access or do it server side with a SQL job, not sure which is best for your situation given the limited information provided

月亮坠入山谷 2024-09-21 00:28:19

您可以在 SQL 中内联引用 SQL Server 数据库或 MS Access 数据库:

UPDATE SQLTable (ID, Stuff) 
SELECT ID, Stuff
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
   'c:\External\MyAccess.mdb';'admin';'', Table1) 

-- 来自数据库日志

您可以使用 ADO 连接到 SQL Server 来执行此查询

-- 连接字符串

您还可以使用 ODBC 从访问端执行相同操作

Dim cn As New ADODB.Connection

scn = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" _
    & DBFullName
cn.Open scn

s = "INSERT INTO [ODBC;Description=TEST;DRIVER=SQL Server;" _
& "SERVER=Server\Instance;Trusted_Connection=Yes;" _
& "DATABASE=test].Table2 (ID, Stuff) SELECT ID, Stuff FROM Table1"
cn.Execute s

您可以使用 VBScript 或其他合适的脚本运行 ADO 并使用 Windows任务计划程序以适当的时间间隔启动脚本。这并非没有痛苦。

You can refer to either the SQL Server database or the MS Access database inline in your SQL:

UPDATE SQLTable (ID, Stuff) 
SELECT ID, Stuff
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
   'c:\External\MyAccess.mdb';'admin';'', Table1) 

-- From databasejournal

You can execute this query using ADO with a connection to SQL Server

-- Connection strings

You can also do the same from the Access end with ODBC

Dim cn As New ADODB.Connection

scn = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" _
    & DBFullName
cn.Open scn

s = "INSERT INTO [ODBC;Description=TEST;DRIVER=SQL Server;" _
& "SERVER=Server\Instance;Trusted_Connection=Yes;" _
& "DATABASE=test].Table2 (ID, Stuff) SELECT ID, Stuff FROM Table1"
cn.Execute s

You can run ADO with VBScript, or other suitable script and use Windows Task Scheduler to kick the script off at suitable intervals. This is not without pain.

腻橙味 2024-09-21 00:28:19

您可以尝试将 MS Access 数据库链接到 SQL Server,
现在您可以从 MS Access 中的 SQL Server 查询数据。
我不知道 MS ACCESS 上的触发器,但您可以在中实现一些循环
MS SQL 进行周期性计数或选择数据以检查新数据。
要在对象资源管理器上的 SQL MGM Studio 中创建链接服务器 ->服务器对象->链接服务器->右键单击->新的链接服务器
然后在新查询中简单调用任何表,例如

Select * from [linked server].dbo.mytable

在 MS SQL 中,有 WAITFOR 命令< /a> 您可以实施

You can try to link MS Access database to SQL server,
Now you can querying data from SQL server which is in MS Access.
I do not know about trigers on MS ACCESS but you can implement some loops in
MS SQL to periodicity count or select data for cheking new one.
To make linked server in SQL MGM Studio on Object Explorer -> Server Object -> Linked server -> right click -> New linked server
After then in new query simple call any table like

Select * from [linked server].dbo.mytable

In MS SQL there is WAITFOR command which You can implement

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文