gpt4 book ai didi

excel - 语言服务提交: Error '91'

转载 作者:行者123 更新时间:2023-12-02 12:09:10 26 4
gpt4 key购买 nike

我按照下面链接中发布的解决方案通过 VBA 执行简单的 SAS 查询: Calling SAS through VBA

Dim obObjectFactory As New SASObjectManager.ObjectFactory
Dim obObjectKeeper As New SASObjectManager.ObjectKeeper
Dim obServer As New SASObjectManager.ServerDef
Dim obSAS As SAS.Workspace
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
obServer.MachineDNSName = "xxxx@company.com"
obServer.Protocol = ProtocolBridge
obServer.Port = 8561
obObjectFactory.LogEnabled = True
Set obSAS = obObjectFactory.CreateObjectByServer("sas", False, obServer, "", "")
obSAS.LanguageService.Submit "PROC SQL; CREATE TABLE ME.TABLE1; RUN;" 'Error at submit

但是我在上面的提交行收到错误“对象变量或未设置 block 变量”

最佳答案

您正在尝试创建异步连接。我会尝试创建同步连接(将第二个参数更改为 true)。

Set obSAS = obObjectFactory.CreateObjectByServer("sas", True, obServer, "", "")

Synchronous indicates whether a connection is synchronous or asynchronous. The synchronous connection is most frequently used and is the simplest connection to create. If this parameter equals TRUE, CreateObjectByServer does not return until a connection is made. If this parameter equals FALSE, the function returns a null value immediately. When a connection is made, the object is stored in the ObjectKeeper.

来自 SAS 文档。这就是为什么你的变量马上就变成Nothing了。

http://support.sas.com/rnd/itech/doc9/dev_guide/dist-obj/winclnt/omcreate.html

现在对于 Submit 方法,我建议您添加一些错误检查代码,例如

If obSAS Is Nothing Then
MsgBox("Connection failed")
Else
obSAS.LanguageService.Submit "PROC SQL; CREATE TABLE ME.TABLE1; RUN;" 'Error at submit
End If

上面的内容将回答您为什么收到错误对象变量或未设置 block 变量的问题。

对于后面的运行时错误“-2147213310 (80042002)”,这是一个不同的问题。您应该尝试联系 SAP 技术支持,根据您提供的信息,我们无能为力。该错误必须以 html 标记的形式为您提供附加信息。从您提供的链接来看,此错误似乎是由错误的连接设置/参数引起的。

The workspaceservers default port is 8591. Perhaps the workspaceserver also runs on a different machine. Connect to your profile, go to the serverlist, locate the server you want to connect to and right click the context menu "properties" to see the right connection profile for your workspaceserver.

BTW: if you are using IWA (integrated windows authentication) you must not provide a username and password (Nothing).

Set obSAS = obObjectFactory.CreateObjectByServer("sas", True, obServer, Nothing, Nothing)

关于excel - 语言服务提交: Error '91' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49639181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com