我在使用传输类传输带有数据的数据库时遇到问题。它工作正常,无需传输数据。有了我得到的数据
错误:错误代码 = -1071636471 描述 = SSIS 错误代码 DTS_E_OLEDBERROR。
发生 OLE DB 错误。错误代码 0x800040005/ oledb 记录可用。来源:“Microsoft SQL Server Native Client 10.0” Hresult:0x80004005 描述:2登录失败。登录来自不受信任的域,不能与 Windows 身份验证一起使用”
该类有一个属性transfer.DestinationLoginSecure = false;
,当设置为 false 时,不使用集成安全性。我尝试设置各种属性无济于事。
在我使用它的所有其他实例中连接良好的连接字符串。
using (SqlConnection conn = new SqlConnection(Connections.dbConnection_HTOUTER()))
{
conn.Open();
Server server = new Server(new ServerConnection(conn));
Database dbMaster = server.Databases[ConfigurationManager.AppSettings.Get("dbMaster")];
Database dbProduction = server.Databases[ConfigurationManager.AppSettings.Get("dbProduction")];
Transfer transfer = new Transfer(dbMaster);
string login = ConfigurationManager.AppSettings.Get("login");
string password = ConfigurationManager.AppSettings.Get("password");
transfer.CopyAllObjects = true;
transfer.CopyAllUsers = true;
transfer.Options.WithDependencies = true;
transfer.Options.ContinueScriptingOnError = true;
transfer.DestinationServer = server.Name;
transfer.DestinationDatabase = dbProduction.Name;
transfer.DestinationLoginSecure = false;
transfer.DestinationPassword = password;
transfer.DestinationLogin = login;
transfer.CopyAllRules = true;
transfer.CopyAllRoles = true;
//transfer.CopyAllObjects = true;
transfer.DropDestinationObjectsFirst = true;
transfer.CopySchema = true;
transfer.CopyData = true;
transfer.CreateTargetDatabase = false;
transfer.Options.IncludeIfNotExists = true;
transfer.Options.Indexes = true;
transfer.TransferData();
}