2013-03-05 2 views
1

У меня возникли проблемы с передачей базы данных данными с использованием класса переноса. Он отлично работает без передачи данных. С данными я получаюSQL Authentication for Transfer class

ERROR: error code= -1071636471 description = SSIS Error code DTS_E_OLEDBERROR.

An OLE DB error has occured. Error code 0x800040005/ An oledb record is avialable. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: 2Login failed. The login is from an untrusted domain and cannot be used with windows authentication"

Класса имеет свойство transfer.DestinationLoginSecure = 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(); 


      } 
+0

См: http://stackoverflow.com/a/17676149/220230 – Piedone

+0

Джед я, вы когда-нибудь получить где-нибудь с этим? У меня такая же проблема. – faroligo

ответ

0

Вы должны установить, пользователь, пароль происхождения и назначения сервера вручную.

Это будет работать:

SqlConnectionStringBuilder connectionBuilderOriginDatabase = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["ORIGIN"].ConnectionString); 

ServerConnection originConnection = new ServerConnection(connectionBuilderOriginDatabase.DataSource); 
originConnection.LoginSecure = false;//very important 
originConnection.Login = connectionBuilderOriginDatabase.UserID; 
originConnection.Password = connectionBuilderOriginDatabase.Password; 

Server server = new Server(originConnection); 
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; 

//Here you are configuring the destination server 
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;