gpt4 book ai didi

c# - SQL Server 管理对象

转载 作者:太空狗 更新时间:2023-10-29 21:55:52 25 4
gpt4 key购买 nike

我在使用受信任或 SQL 登录的以下代码中遇到相同的错误:

VS2010, Console app .NET4, Win XP. SQL2005 Full.

传输中的炸弹.TransferData

ERROR : errorCode=-1073548784 description=Executing the query "" failed with the following error: "Retrieving the COM class factory for component with CLSID {19E353EF-DAF4-45D8-9A04-FB7F7798DCA7} failed due to the following error: 80040154.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

这感觉很安全。任何想法都会很棒!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Collections.Specialized;
using System.IO;
using System.Configuration;


namespace GenerateScripts
{
class Program
{
static void Main(string[] args)
{
ServerConnection sourceConnection = new ServerConnection("localhost");
Server sourceServer = new Server(sourceConnection);
//sourceServer.ConnectionContext.LoginSecure = false;
//sourceServer.ConnectionContext.Login = "3tier";
//sourceServer.ConnectionContext.Password = "3tier";
Database sourceDatabase = sourceServer.Databases["3tier"];


// destination
ServerConnection destinationConnection = new ServerConnection("localhost");
Server destinationServer = new Server(destinationConnection);
//destinationServer.ConnectionContext.LoginSecure = false;
//destinationServer.ConnectionContext.Login = "3tier2";
//destinationServer.ConnectionContext.Password = "3tier2";
Database destinationDatabase = destinationServer.Databases["3tier2"];

Transfer transfer = new Transfer(sourceDatabase);
transfer.CopyAllObjects = false;
transfer.DropDestinationObjectsFirst = false;
transfer.UseDestinationTransaction = true;

transfer.CopyAllDefaults = true;
transfer.Options.Indexes = true;
transfer.Options.DriAll = true;
transfer.CopyAllDefaults = true;

transfer.Options.AnsiFile = true;
transfer.Options.SchemaQualify = true;
transfer.Options.WithDependencies = false;
transfer.CreateTargetDatabase = false;
transfer.CopySchema = true;
transfer.CopyData = true;

transfer.DestinationServer = "localhost";
transfer.DestinationDatabase = "3tier2";
transfer.DestinationLoginSecure = false;
transfer.DestinationLogin = "3tier2";
transfer.DestinationPassword = "3tier2";

transfer.Options.IncludeIfNotExists = true;
transfer.TransferData();

最佳答案

我不知道这是否是同一种情况,但我遇到了类似的问题,它与 SQLTaskConnectionOleDb 类注册损坏有关,

我已经通过运行解决了它

regsvr32 "%ProgramFiles%\Microsoft SQL Server\90\DTS\Binn\SQLTaskConnections.dll"

在命令提示符下。

关于c# - SQL Server 管理对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3384649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com