2013-03-05 59 views
1

我遇到的問題是使用傳輸類傳輸數據庫與數據。它工作正常,無需傳輸數據。隨着數據我得到傳輸類的SQL身份驗證

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"

類有其設置爲false時,不使用intergrated安全屬性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 2014-03-06 00:45:51

+0

傑德我,你有沒有與此取得任何進展?我有完全相同的問題。 – faroligo 2014-08-22 11:22:47

回答

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; 
相關問題