Use the ADO to operate SQL Server through the 'OLE DB Access Database, implement data exchange

zhaozj2021-02-11  180

Introduction of stored procedures 1, sp_addlinkedserver --- SQL SERVER to add a Link Server2, sp_addlinkedsrvlogin --- add a Login3 to Link Server, sp_droplinkedsrvlogin --- delete Link Server's Login4, sp_dropserver --- Link Server Refer to delete SQL Server Book Online Command 1, Use Switch to a specified database 2, OpenQuery executes a query from an existing Link Server

Dim cn As ADODB.Connection Dim strsql As String Dim rs As ADODB.Recordset 'open connection Set cn = New ADODB.Connection cn.Open "connected" strsql = "use master" cn.Execute strsql' add a LinkServer strsql = "exec sp_addlinkedserver "strsql = strsql &" @server = 'AccessDataSrv', "strsql = strsql &" @provider = 'Microsoft.Jet.OLEDB.4.0', "strsql = strsql &" @srvproduct = 'OLE DB Provider for Jet', "Strsql = strsql &" @datasrc = 'c: /test.mdb' "cn.execute strsql 'Add a LinkServer login If your database has password and user authentication,' strsql =" Exec sp_addlinkedsrvlogin 'accessDataSRV', 'False' , 'Current User', 'User', 'Password'

转载请注明原文地址:https://www.9cbs.com/read-5535.html

New Post(0)