[英]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.