我试图运行此代码,但它显示错误"重载解析失败"。
Conn = New OleDbConnection(ConnectionString)
Dim serverConn As New Server(New ServerConnection(Conn))
以下是完整错误:
Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(serverInstance As String)': Value of type 'System.Data.OleDb.OleDbConnection' cannot be converted to 'String'.
'Public Sub New(sqlConnection As System.Data.SqlClient.SqlConnection)': Value of type 'System.Data.OleDb.OleDbConnection' cannot be converted to 'System.Data.SqlClient.SqlConnection'.
'Public Sub New(sci As Microsoft.SqlServer.Management.Common.SqlConnectionInfo)': Value of type 'System.Data.OleDb.OleDbConnection' cannot be converted to 'Microsoft.SqlServer.Management.Common.SqlConnectionInfo'.
答案 0 :(得分:0)
如果要管理MS SQL Server,则需要SqlConnection
,而不是通用OleDbConnection
。
将OleDbConnection
替换为SqlConnection
,或将ConnectionString
权限传递给New Server()
,而不首先实例化显式连接。