从.NET中的SAS数据源读取数据 [英] Reading data from a SAS data source in .Net

查看:152
本文介绍了从.NET中的SAS数据源读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在问一个ASP.Net应用程序读取来自SAS的一些数据。我有工作code为Windows窗体应用程序。但是,同样code的的在ASP.Net工作,不过,我可以试试。与同标号A清洁工程始终失败。

I've been asked to read some data from SAS in an ASP.Net application. I've got working code for a Windows Forms app. However the same code doesn't work in ASP.Net however I can try it. A clean project with the same references consistently fails.

下面就是我得到了连接:

Here's what I've got for the connection:

    SASWorkspaceManager.WorkspaceManager oWorkspaceManager
        = new SASWorkspaceManager.WorkspaceManager();
    string xmlInfo = "";

    SASWorkspaceManager.ServerDef oServerDef = new SASWorkspaceManager.ServerDef();
    oServerDef.MachineDNSName = "server";
    oServerDef.Protocol = SASWorkspaceManager.Protocols.ProtocolBridge;
    oServerDef.Port = <port>;
    oServerDef.BridgeEncryptionAlgorithm = "SASProprietary";
    oServerDef.BridgeEncryptionLevel = 
        SASWorkspaceManager.EncryptionLevels.EncryptUserAndPassword;

    SAS.Workspace oSASWorkspace = 
        oWorkspaceManager.Workspaces.CreateWorkspaceByServer ("", 
        SASWorkspaceManager.Visibility.VisibilityProcess, oServerDef, "user",
        "pass", out xmlInfo);

    oSASWorkspace.LanguageService.Submit(
        "proc means data = sashelp.class;output out=meanout;run;");
    OleDbDataAdapter oOleDbDataAdapter = new OleDbDataAdapter
                            ("select * from work.meanout",
        "provider=sas.iomprovider.1; SAS Workspace ID=" + 
        oSASWorkspace.UniqueIdentifier);
    DataSet oDS = new DataSet();
    oOleDbDataAdapter.Fill(oDS, "sasdata");

    oWorkspaceManager.Workspaces.RemoveWorkspaceByUUID(
        oSASWorkspace.UniqueIdentifier);
    oSASWorkspace.Close();

使用只是它失败的内部异常初始化数据适配器
尝试读取或写入受保护的内存。这通常是指示其他内存已损坏。如果我添加信托=完整的web.config文件我直接得到同样的错误填充数据适配器时。我们可以证明,通过工作区管理器执行SAS命令工作,这时候,我们再尝试读取结果反馈,它初始化到SAS连接时失败。无论出于何种原因,片段

With just that it fails initialising the data adapter with an inner exception of "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." If I add Trust=Full to the web.config file I get the same error directly when filling the data adapter. We can prove that executing the SAS command via the workspace manager is working, it's when we then try to read the results back that it fails when initialising the connection to SAS. For whatever reason, the fragment

OleDbDataAdapter oOleDbDataAdapter = new OleDbDataAdapter
                        (<Read Command>,
    "provider=sas.iomprovider.1; SAS Workspace ID=" + 
    oSASWorkspace.UniqueIdentifier);

这似乎随处列为怎么做它只是不断通过时运行ASP.Net引发错误。

which seems to be cited everywhere as how to do it just keeps raising an error when run through ASP.Net.

我猜这是一个用户权限问题的地方它不顺心的IIS用户下运行,但不知道需要授予的权限。某些SAS单证地方或其他(抱歉,不能找到它)建议确保用户有权限,但ASPNET用户确实有完全访问整个SAS程序目录dev的机器上。有谁知道还有什么我可能需要设置?谢谢你。

I'm guessing it's a user permissions issue somewhere with it not liking running under the IIS user but wouldn't know what needs permissions granted to it. Some SAS documentations somewhere or other (sorry, can't find it) suggested making sure the user had permissions, but the ASPNET user does have full access to the whole SAS program directory on the dev machine. Does anyone know what else I might need to set? Thanks.

推荐答案

我运行在IIS类似的东西时,碰到了几个问题。首先,你必须调整SAS工作区组件上的权限管理工具 - >组件服务。你必须添加权限为您的应用程序池下运行的用户。这将是在组件的属性窗口 - >安全选项卡 - >启动和激活权限,还访问权限

I ran into a couple of issues when running something similar in IIS. First, you'll have to adjust the permissions on the SAS Workspace component in admin tools -> component services. You'll have to add permissions for the user that your application pool is running under. This will be under the properties windows of the component -> security tab -> launch and activation permissions, and also the access permissions.

我也结束了不必修改SASUSER目录中的配置,因为网络服务没有访问权限。

I also ended up having to modify the SASUSER directory in the config because network service didn't have access.

C:\\ Program Files文件\\ SASHome \\ SASFoundation \\ 9.3 \\ NLS \\ EN \\ sasv9.cfg

C:\Program Files\SASHome\SASFoundation\9.3\nls\en\sasv9.cfg

/ * - * SASUSER /CSIDL_PERSONAL \\我的SAS文件\\ 9.3?
-SASUSERC:\\ SASUSER

/*-SASUSER "?CSIDL_PERSONAL\My SAS Files\9.3" */ -SASUSER "c:\sasuser"

这篇关于从.NET中的SAS数据源读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆