Sql vb.net服务器连接重载

Sql vb.net服务器连接重载,sql,vb.net,smo,Sql,Vb.net,Smo,我正在尝试运行此代码,但它显示错误重载解析失败 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(ser

我正在尝试运行此代码,但它显示错误重载解析失败

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'.   

如果要管理MS SQL Server,则需要SqlConnection,而不是通用OLEDB连接

用SqlConnection替换OleDbConnection,或者将ConnectionString直接传递到新服务器,而不首先实例化显式连接