I created SSIS package using integration service project in vs 2015.
My connection establishment is successful using Datasource. I can execute package using Execute Package Utility and Command line which is successful.
Please check below screens shots for the same.
I am facing problem while executing same package using c#. getting failed to execute package.
I have applied eventlistener, getting below error.
Please find below few screenshots for more information.
Code for reference:
Application app = new Application();
Package pkg = app.LoadPackage(#"C:\Project\Sample\Package1.dtsx", listener);
DTSExecResult results = pkg.Execute(null, null, listener, null, null);
In results object i got failure with given error.
As #Tab Alleman says you can run the package by calling a stored procedure sp_start_job from C# that starts SQL Agent JOB.
Here a piece of code that can be of help in this type of approach, after creating the SQL Agent JOB:
SqlConnection Conn = new SqlConnection(YOURCONNECTION);
SqlCommand ExecuteJob = new SqlCommand();
ExecuteJob.CommandType = CommandType.StoredProcedure;
ExecuteJob.CommandText = "msdb.dbo.sp_start_job";
ExecuteJob.Parameters.AddWithValue("#job_name", YOURJOBNAME")
ExecuteJob.Connection = Conn;
using (Conn)
{
Conn.Open();
using (ExecuteJob)
{
ExecuteJob.ExecuteNonQuery();
}
}
I hope this help.
Unfortunately your output does not show what the exact error message is. I have had problems in the past executing packages directly from C#.
One way around this is to create a SQL Agent job that executes the package, and then call a stored procedure from C# that starts the SQL Agent Job.
Related
I'm trying to create a database in memory and run a query with .NET Core 2.1 framework. To do this I have installed a package called Microsoft.Data.Sqlite.Core and then tried to do the following:
var connection = new SqliteConnection("Data Source=:memory:");
connection.Execute("Some Create Table Query");
And my code will crash with the following error:
You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().
I've done a lot of digging to find a solution and one of them suggested calling this:
SQLitePCL.raw.SetProvider(new SQLite3Provider_e_sqlite3());
This produces me a new error:
'Unable to load DLL 'e_sqlite3' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
I am really lost at this point how to accomplish this. All I want to do is create an in-memory database so I can run some queries for purposes of unit testing.
I'm not sure if this is relevant but I am not using EF6, I am using Dapper and also I am using SQL Server in my actual project. I wanted to plug in Sqlite in unit tests so I can also test my queries.
I have a feeling I am using wrong packages, but looking around there are so many and I can't find any clear documentation on how to use Sqlite with MVC Core projects.
Try adding the SQLitePCLRaw.bundle_green package to your project.
dotnet add package SQLitePCLRaw.bundle_green
At that point, the following program (inspired by this) works:
using Microsoft.Data.Sqlite;
class Program
{
static void Main()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var createCommand = connection.CreateCommand();
createCommand.CommandText =
#"
CREATE TABLE data (
value TEXT
)
";
createCommand.ExecuteNonQuery();
}
}
This is the test that I ran locally.
cd C:/temp
dotnet new console
dotnet add package Microsoft.Data.Sqlite.Core
dotnet add package SQLitePCLRaw.bundle_green
//
// paste the above program into Program.cs, then...
//
dotnet run
What is bundle_green? bundle_green is one of the Sqlite "bundle packages", which are expressly designed to ease cross-platform development. Here is a description from the official repository:
These packages automatically bring in the right dependencies for each platform. They also provide a single Init() call that is the same for all platforms... SQLitePCLRaw.bundle_green is a bundle that uses e_sqlite3 everywhere except iOS, where the system-provided SQLite is used.
I'm trying to run a local SSIS package from a C# console application. I've built both the package and the application using .Net 4.5.1 in VisualStudio 2012. When I say "local" I mean the SSIS package hasn't been deployed to a SQL Server; I'm just trying to call the .dtsx file from the file system. The SSIS package runs fine from within VisualStudio. Here's my code:
string pkgLocation = #"C:\Users\06717\Documents\Visual Studio 2012\Projects\RMA_Data_Cleanup\RMA_Data_Cleanup\";
string pkgName = "Package.dtsx";
Application app = new Application();
Package pkg = new Package();
DTSExecResult pkgResults = new DTSExecResult();
try
{
pkg = app.LoadPackage(pkgLocation + pkgName, null);
There's more after this, obviously, but the problem comes with the app.LoadPackage line. When I try to run it, this exception gets thrown:
The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails.
I've googled this error message, and I haven't found anything that seems to apply to my case. One thing that occurs to me is that maybe I'm calling the wrong dtsx file. There's another one in the obj\Development folder. I've tried calling that one too, but I get the same exception. Am I calling the right file? Is there something I need to do from within Visual Studio, other than build the package, before I can do this? (pkgResults = Success, BTW)
The following Database connection code is working in one project but not for other.
Both
Reside in the same folder
Accessing the same Oracle.dataaccess dll
I am unable to understand what might have led the other project not connect to oracle DB.
I am out of ideas on how to make this project use the connection strings in the tnsnames.ora.
Any help is appreciated
Code:
string constr = "Data Source=Dev11G;User Id=Username;Password=pwd;";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleCommand cmd = new OracleCommand("Select * from Table", con);
cmd.CommandType = CommandType.Text;
DataTable dt = new DataTable();
using (OracleDataAdapter da = new OracleDataAdapter())
{
da.SelectCommand = cmd;
da.Fill(dt);
}
Error being Recieved: ORA-12154:TNS:could not resolve the connect identifier specified
Error occuring at: con.Open();
Have you tried using EZCONNECT instead of using TNS Names? TNS Names is convenient on a client (with IDEs, etc), but any time you have to deploy an application, you're dependent on whomever maintains that machine. If they update TNS names, it could potentially interfere with your application.
The connection string can be as simple as:
string conString = String.Format("Direct=true;Data Source={0};Port={1};" +
"Service Name={2};User={3};Password={4};Connection Timeout={5}", ...
If you don't know these values, you can find a machine where it's set up correctly and:
tnsping Dev11G
Thanks for all of your posts.I finally found it.it has to do with the local IIS server settings.The project that is succesfully connecting to Oracle is using visual studio development server...while the other one which is unable to connect is using local IIS server.So I have to grant the IIS access to the tnsnames.ora folder.
This post really helped me...
Oracle ORA-12154 error on local IIS, but not with Visual Studio Development Server
I have an installation package (Visual studio installer). During the installation process i attach a database to MS Sql server using SMO.
When the uninstallation process is started the dialog "The following applications ("SQL server(MSSQLServer)") should be closed before continuing the install" appears. The dialog has two options "Automatically close applications and attempt to restart them after setup is complete" and "Do not close applications(A Reboot may be required)". if i select first one option, i see the error "cannot connect at server". With the second option all works correctly.
In the unistall method of my custom action i use SqlCommand (command text: DROP DATABASE [baseName]) for deleting database.
Uninstall method code:
using(var con=new SqlConnection(_server.ConnectionContext.ConnectionString))
{
con.Open();
string sqlCommandText = string.Format("DROP DATABASE [{0}]", DATABASE_NAME);
var sqlCommand = new SqlCommand(sqlCommandText, con);
sqlCommand.ExecuteNonQuery();
}
How can i avoid the dialog "The following applications ..." and always use the second option? Or maybe there i some other way for deleting db?
Can someone help me out please, as google is not providing the answers.
I've got a SharePoint 2007 setup which uses SQL Server 2008 R2 SSAS OLAP cubes via some web parts.
As a C# developer, Sharepoint is a nightmare, so I decided I needed to try to get to grips with just C# and OLAP interaction. My cubes all exist, and are working, so all I needed to do was create a simple C# App to get it all straight in my mind.
I've downloaded Microsoft.AnalysisServices v10.0.0.0 and I can see it sitting happily in my GAC, but I can't add a reference from within my Visual Studio 2010 C# 4.0 project. It's just notappearing. I've tried setting the app to use 3.5, but still no joy.
Any clues?
Have you added the reference for Microsoft.AnalysisServices.AdomdClient.dll located in C:\Program Files\Microsoft.NET\ADOMD.NET\100
You could also use the nuget package manager. Type this in the console
Deprecated version (does not exist anymore):
install-package Microsoft.AnalysisServices.AdomdClient
New version:
Install-Package Microsoft.AnalysisServices.AdomdClient.retail.amd64
I think you need to reference the file directly, rather than through the GAC. It should be located in C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies
AdomdConnection steps
AdomdConnection con = new AdomdConnection("connectionstring"); // connect DB
con.Open();
AdomdCommand cmd = new AdomdCommand("MDX query", con); //query
AdomdDataReader reader = cmd.ExecuteReader(); //Execute query
while (reader.Read()) // read
{
Data dt = new Data(); // custom class
dt.Gender = reader[0].ToString();
dt.Eid = reader[1].ToString();
dt.salary = reader[2].ToString();
data.Add(dt);
}