【问题标题】:Access 2010 linked table checkAccess 2010 链接表检查
【发布时间】:2012-03-11 05:35:45
【问题描述】:

我被难住了。我有一个有两个后端的数据库。一个在网络上是本地的,另一个在 Internet 上。当我的数据库启动时,用户必须通过登录,一旦发生这种情况,主窗体就会打开。此时,运行查询以通过链接表通过 Internet 将数据从本地后端发送到外部后端。我要做的是检查链接表是否有连接,并且仅在链接表已连接时才运行此查询。这样做的原因是,如果最终用户或数据库通过 Internet 连接的服务器在锁定用户前端时没有 Internet 连接。这不好,因为如果 Internet 连接丢失或服务器因任何此类原因出现故障,这将限制用户使用数据库

Example: if sql link is ok then
         run query
         Else goto end

【问题讨论】:

  • 表格名称为“ACTIVE”
  • 这有可能还是我找错树了?

标签: sql ms-access connection ms-access-2010


【解决方案1】:

你应该可以使用FileSystemObject在网络上获取一个合适的文件夹,如果失败,你没有连接。

编辑

This article 使用 VBScript 检查 SQL Server 端口。 VBScript 在 VBA 中运行,几乎没有什么变化。

编辑#2

Powershell 可用于 ping 远程服务器和can be run from VBA

$servers = Get-Content 'servers.txt'
ForEach-Object ($server in $servers) {
   # Ping the machine to see if it's on the network
   $results = Get-WMIObject -query "select StatusCode from
Win32_PingStatus where Address = '$server'"
   $responds = $false  
   ForEach-Object ($result in $results) {
      # If the machine responds break out of the result loop and indicate success
      if ($result.statuscode -eq 0) {
         $responds = $true
         break
      }
   }
         If ($responds) {
      # Gather info from the server because it responds
      Write-Output "$server responds"
   } else {
      # Let the user know we couldn't connect to the server
      Write-Output "$server does not respond"
   }
}

上面的代码是从 Allen White 的http://www.simple-talk.com/sql/database-administration/let-powershell-do-an-inventory-of-your-servers/ 剪切和粘贴的

【讨论】:

  • 谢谢你看看这个,这是否可以通过互联网工作到只有端口 1433 和 1434 对 sql 开放的服务器上,只有其余的被锁定
  • 非常感谢您为我提供了基础知识,但它似乎报告本地网络 sql 是否处于活动状态,并且在大多数情况下,本地 sql 仍然是活动的,但不是网络上的外部 sql 使用这条鳕鱼我也可以指定一个 IP 吗?
  • 非常感谢到目前为止的帮助。我让我玩过我展示给我的电源外壳夹,但我在两个地方遇到了意外的令牌错误。另外我想知道如果这个外部操作“通过测试”,我将如何开始查询。 vba 有这个的衍生物吗?请注意,这是我第一次遇到 powershell
  • 好吧,这就是我从 sn-ps 中得出的结论,我在这个地方发现了所有作者后,我会给予信任,
  • Private Sub Detail_Click() Dim strComputer As String strComputer = "ip Adress here" If Not SystemOnline(strComputer) Then MsgBox "This computer is current unreachable:" & strComputer, vbOKOnly, "Computer Status" ' ....你的逻辑 Else '...你的逻辑 MsgBox "This computer is Online!", vbOKOnly, "Computer Status" End If End Sub 'TestPing '
猜你喜欢
  • 1970-01-01
  • 2015-11-12
  • 1970-01-01
  • 2015-07-07
  • 1970-01-01
  • 2017-05-13
  • 2014-04-14
  • 2014-06-19
  • 1970-01-01
相关资源
最近更新 更多