几天来我一直在寻找解决方案,但似乎仍然找不到。我在脚本组件中获取连接时遇到问题。我需要查询我的数据库以检索要使用的 Id,然后再将其插入
public override void AcquireConnections(object Transaction)
{
connMgr = base.Connections.Connection;
conn = (SqlConnection)connMgr.AcquireConnection(null);
}
我在这里得到一个例外。
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.SqlClient.SqlConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
有什么解决办法吗?