Am getting the same error on the code below using either trusted or SQL logins:
VS2010, Console app .NET4, Win XP. SQL2005 Full.
Bombs on the transfer.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.
this feels like security. Any thoughts would be awesome!
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();
I don't know if this is the same case but i had a similar problem and it was related to SQLTaskConnectionOleDb class registration corruption,
i've solved it by running
regsvr32 "%ProgramFiles%\Microsoft SQL Server\90\DTS\Binn\SQLTaskConnections.dll"
in command prompt.
Related
I'm making a VPN connection using DOTRAS in C# by the click of a button, using the following method.
string VpnName = "Test1";
string Destination = "191.20.0.21";
string PresharedKey = "myKey";
RasPhoneBook PhoneBook = new RasPhoneBook();
PhoneBook.Open();
RasEntry VpnEntry = RasEntry.CreateVpnEntry(VpnName, Destination, DotRas.RasVpnStrategy.L2tpOnly, DotRas.RasDevice.Create(VpnName, DotRas.RasDeviceType.Vpn));
VpnEntry.Options.UsePreSharedKey = true;
VpnEntry.Options.UseLogOnCredentials = true;
VpnEntry.Options.RequirePap = true;
VpnEntry.Options.RequireMSChap = false;
VpnEntry.Options.RequireMSChap2 = false;
PhoneBook.Entries.Add(VpnEntry);
VpnEntry.UpdateCredentials(RasPreSharedKey.Client, PresharedKey);
Console.WriteLine("VPN connected successfully");
The VPN connects successfully.
I need to disconnect it now (Something other than simply removing it).
How will that be possible?
here:
var conn = RasConnection.GetActiveConnections().Where(c => c.EntryName == "Test1").FirstOrDefault();
if (conn!=null)
{
conn.HangUp();
}
Hey Guys i have had a problem with this line in my code while trying to insert to customers table in NAV id really appreciate any feedback and possible solutions to my problem.
service.Create(ref custArray);
the full code i'm implementing is as follows; **kenedy is my webservice.
namespace PrintCustomerList
{
// Import newly generated Web service proxy.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using kenedy;
using System.Diagnostics;
using System.Xml;
class Program
{
static void Main(string[] args)
{
var service = new Customer_Service();
service.UseDefaultCredentials = true;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Url = "http://..:7047/DynamicsNAV90/WS/..%20LIMITED/Page/Customer";
// Create instance of customer.
Customer custArray = new Customer();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\\Users\\..\\Desktop\\Product.xml");
var nodeList = xmlDoc.DocumentElement.SelectNodes("/Table/Product");
for(var i = 0; i < nodeList.Count; i++)
{
foreach (XmlNode node in nodeList)
{
custArray.Address = node.SelectSingleNode("Product_id").InnerText;
custArray.Name = node.SelectSingleNode("Product_name").InnerText;
custArray.Address_2 = node.SelectSingleNode("Product_price").InnerText;
Console.WriteLine(custArray.Name);
}
}
Console.WriteLine("Records Inserted");
Console.WriteLine("End of Customers");
Console.WriteLine("Press [ENTER] to exit program!");
Console.ReadLine();
service.Create(ref custArray);
// service.Update(ref custArray);
//service.CreateMultiple(ref custArray);
// Create instance of service and set credentials.
}
}
}}
You need to declare a user that has the right to post data. Change your credentials to:
NetworkCredential cred = new NetworkCredential("user", "password", "domain");
service.Credentials = cred;
hit me up with the error if it throws one!
I have a simple restore function. But the problem, is that DeviceType could not be found. I checked my namespaces and they seem to be the only ones I need. Maybe even more. Is there something wrong?
The name 'DeviceType' does not exist in the current context
public void RestoreDatabase(String databaseName)
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
var connection = new ServerConnection(connectionString);
var sqlServer = new Server(connection);
var rstDatabase = new Restore();
rstDatabase.Database = databaseName;
rstDatabase.Action = RestoreActionType.Database;
rstDatabase.Devices.AddDevice(AppDomain.CurrentDomain.BaseDirectory + "GC.bak", DeviceType.File);
rstDatabase.ReplaceDatabase = true;
rstDatabase.SqlRestore(sqlServer);
}
Here is my Namespaces
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Server;
UPDATE
I try to build my application and these are the warnings and errors that come up
And yes, I do have SmoExtended referenced as well.
I am going with the Entity Framework code first approach and am finding that queries to grab just 350 records or so is taking about 8 seconds. How can I speed this up? Is this Universe or Entity Framework that is being slow?
Entity Framework 5.0
U2.Data.Client 1.2.1
.Net Framework 4.5.1
RAMContext looks something like this :
public class RAMContext : DbContext
{
public RAMContext() { }
public DbSet<Policy> Policies { get; set; }
}
Here is the code to grab the entities :
List<Policy> policies = null;
Database.SetInitializer<RAMContext>(null);
using (RAMContext context = new RAMContext())
{
policies = (from p in context.Policies
where p.AGENT_NO == id
select p).ToList();
}
Here is the connection string :
<add name="RAMContext" connectionString="Database=<account>;UserID=<userid>;Password=<pwd>;Server=<server>;Pooling=false;ServerType=universe;ConnectTimeout=360;SleepAfterClose=300;PersistSecurityInfo=true" providerName="U2.Data.Client" />
AGENT_NO is indexed and the same query ran directly on the DB from TCL finishes almost instantly.
EDITED
After the comments from Rajan I tried the following :
policies = (from p in context.Policies
where p.AGENT_NO == id
select new PolicyModel
{
//Type = PolicyModel.Types)StringValue.GetEnumValueByStringValue(typeof(PolicyModel.Types), p.TYPE),
Insured = p.INSURED,
City = p.CITY,
State = p.STATE,
CancelDate = p.CANC_DT
//IsNew = PickHelper.PickYNNullToBool(p.NEW_RENEW_FLG)
});
I am able to make this select in under 3 seconds now, it appears. I also rebuilt the index on AGENT_NO and I believe that helped considerably.
Trying your second suggestion I get the following exception :
An exception of type 'System.IndexOutOfRangeException' occurred in U2.Data.Client.dll but was not handled in user code
Additional information:
Invalid index -1 for this U2ParameterCollection with Count=0.
Could you please try the following code? This code does not use Entity Framework (LINQ to Entity).
We want to see how UniVerse is behaving without Entity Framework.
You need to do the following:
Create C# Console application
Replace Program.cs file’ s content with the following code
Right Click->Add Reference -> C:\Program Files (x86)\Rocket Software\U2 Toolkit for .NET\U2 Database Provider\bin.NETFramework\v4.0\U2.Data.Client.dll
Change connection string
Change SQL syntax
Run the program. See below screen shot. It shows “Time Taken in Seconds”.
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using U2.Data.Client;
using System.Data;
using System.Diagnostics;
namespace DataAdapter
{
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("start.........................");
Stopwatch sw = new Stopwatch();
sw.Start();
U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
conn_str.UserID = "administrator";
conn_str.Password = "pass";
conn_str.Server = "localhost";
conn_str.Database = "XDEMO";
conn_str.ServerType = "UNIVERSE";
conn_str.Pooling = false;
string s = conn_str.ToString();
U2Connection con = new U2Connection();
con.ConnectionString = s;
con.Open();
Console.WriteLine("Connected...");
U2Command cmd = con.CreateCommand();
cmd.CommandText = "SELECT * FROM PRODUCTS";
DataSet ds = new DataSet();
U2DataAdapter da = new U2DataAdapter(cmd);
da.Fill(ds);
sw.Stop();
TimeSpan elapsed = sw.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", elapsed.Hours, elapsed.Minutes, elapsed.Seconds, elapsed.Milliseconds / 10);
int nSec = elapsed.Seconds;
con.Close();
Console.WriteLine("Time Taken in seconds:" + elapsedTime);
Console.WriteLine("End........................... ");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("Enter to exit:");
string line = Console.ReadLine();
}
}
}
}
I'm using an SSIS script task to try and create a SharePoint subsite. The errors don't tell me anything. I know the problem lies in the ClientContext line. The SQL Server server with SSIS is a separate server from my SharePoint server. Any ideas?
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System.Collections.Generic;
using Microsoft.SharePoint.Client.Utilities;
namespace ST_a1ecfb3e46dc4211ac17435ad3bb67ec
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
try
{
string SiteDescription = "This is my first site creation using Client Object Model.";
int SiteLanguage = 1033;
string SiteTitle = "Test Site";
string SiteUrl = "Test";
bool SitePermissions = true;
string mywebTemplate = "STS#0";
ClientContext clientContext = new ClientContext("http://extranet.domain.local/");
//Retreive the web from the Client Context. This web is the root web by default.
/*Web oWebsite = clientContext.Web;
//Create a new webCreateInformation object to specify the properties of the new site being created.
WebCreationInformation webCreateInfo = new WebCreationInformation();
webCreateInfo.Description = SiteDescription;
webCreateInfo.Language = SiteLanguage;
webCreateInfo.Title = SiteTitle;
webCreateInfo.Url = SiteUrl;
webCreateInfo.UseSamePermissionsAsParentSite = SitePermissions;
webCreateInfo.WebTemplate = mywebTemplate;
//Adding a new site under the root web
Web oNewWebsite = oWebsite.Webs.Add(webCreateInfo);*/
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK);
}
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}