简体   繁体   English

Infopath 2013代码中FileQueryConnection的转换错误

[英]Casting Error on FileQueryConnection in Infopath 2013 Code

I've been working on an infopath form to migrate infopath 2007 to infopath 2013. To bind data to DropDownList controls FileQueryConnection has been used. 我一直在使用infopath表单将infopath 2007迁移到infopath 2013.要将数据绑定到DropDownList控件,已经使用了FileQueryConnection。

 // Retrieve the data connection bound to the Manager drop-down list box
 FileQueryConnection institutionConnection =(FileQueryConnection)DataConnections[ExternalUsersDC];
 // returned by the owssvr.dll with a filter on External Users of Institution
 institutionConnection.FileLocation = GetFileLocation(currentSite, externalUsersGuid, ExternalUserInstitution, institution);
 // Query the data connection to fill the Manager drop-down list box with items
 institutionConnection.Execute();

Here ExternalUsersDC is the name of the infopath connection file. 这里ExternalUsersDC是infopath连接文件的名称。 GetFileLocation method gets the list physical location which works fine as expected. GetFileLocation方法获取列表物理位置,按预期正常工作。

Casting error occurs while trying to DataConnection to FileQueryConnection. 尝试DataConnection到FileQueryConnection时发生转换错误。 Error message as follows; 错误信息如下;

Unable to cast object of type 'Microsoft.Office.InfoPath.Internal.SharePointListAdapterRWQueryAdapterHost' to type 'Microsoft.Office.InfoPath.FileQueryConnection 无法转换“Microsoft.Office.InfoPath.Internal.SharePointListAdapterRWQueryAdapterHost”类型的对象以键入“Microsoft.Office.InfoPath.FileQueryConnection”

I searched everywhere to find a reason and failed. 我到处寻找原因并失败了。 If someone has experience with this issue, please shed some light on my path. 如果有人有这个问题的经验,请详细说明我的道路。

Try AS operator. 尝试AS运营商。 It will try to cast to appropriate type.If Casting is not possible it will fail gracefully by returning NULL . 它将尝试转换为适当的类型。如果不能进行强制转换,它将通过返回NULL优雅地失败。

    FileQueryConnection institutionConnection =DataConnections[ExternalUsersDC] as FileQueryConnection;
 // returned by the owssvr.dll with a filter on External Users of Institution
 institutionConnection.FileLocation = GetFileLocation(currentSite, externalUsersGuid, ExternalUserInstitution, institution);
 // Query the data connection to fill the Manager drop-down list box with items
 institutionConnection.Execute();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Infopath FileQueryConnection.Execute(XpathNavigator)引发System.Net.WebException:尝试读取或写入受保护的内存 - Infopath FileQueryConnection.Execute(XpathNavigator) throws System.Net.WebException: Attempted to read or write protected memory InfoPath 2013开发时出现错误“无法启动调试。 与主机的预调试协商失败。“ - InfoPath 2013 development with error “Cannot start debugging. Pre-debugging negotiations with Host failed.” Infopath 2010另存为2007,代码在2007年之后,生成错误 - Infopath 2010 saved as 2007 with code behind 2007 generate error 如何在Infopath 2013中使用C#读取ADOQueryConnection - How to read an ADOQueryConnection with C# in Infopath 2013 在代码中将CHAR(1)SQL列转换为“ char”时出错 - Error casting CHAR(1) SQL column as “char” in code 部署背后的InfoPath 2007代码 - InfoPath 2007 code Behind Deployment 如何在infoPath中创建提交按钮到SPoint2013 - How To create a submit button in infoPath to SPoint2013 用托管代码动态填充InfoPath DropownList - Dynamically populate an InfoPath DropownList with managed code InfoPath 2010中的规则或代码关闭浏览器窗口 - Rule or code in InfoPath 2010 close the browser window 自升级到Visual Studio 2013以来的投射错误 - Casting Errors Since Upgrade to Visual Studio 2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM