缺少DbProviderFactories.GetFactory方法(DbConnection)

时间:2013-07-23 13:07:40

标签: ado.net

根据MSDN,在.NET 4中有一个GetFactory(DbConnection)的重载。但是,我无法调用它 - 在编译时失败说:

error BC30518: Overload resolution failed because no accessible 'GetFactory' can be called with these arguments:
    'Public Shared Function GetFactory(providerRow As System.Data.DataRow) As System.Data.Common.DbProviderFactory': Value of type 'System.Data.Common.DbConnection' cannot be converted to 'System.Data.DataRow'.
    'Public Shared Function GetFactory(providerInvariantName As String) As System.Data.Common.DbProviderFactory': Value of type 'System.Data.Common.DbConnection' cannot be converted to 'String'.

我的.NET FW有问题还是文档中的拼写错误?

1 个答案:

答案 0 :(得分:0)

您可以拨打" GetFactory"方法使用以下解决方案: https://msdn.microsoft.com/en-us/library/dd0w4a2z%28v=vs.110%29.aspx

DbProviderFactory factory =
            DbProviderFactories.GetFactory(providerName);