SSIS String or binary data would be truncated. The statement has been terminated - asp.net

When I run SSIS package from BIDS it runs fine without any error / problem.
When I try to call it through a ASP.NET website I get the following error -
"String or binary data would be truncated. The statement has been terminated."
I checked all the columns / data to see if anything is exceeding the limit, everything is fine.
I can run the package through command line using dtexec C:>dtexec /f "C:\temp\MyTempPackage.dtsx", it executes without any problem .
The problem is when I try to run it through ASP.NET. The following is the code that I am trying to use -
//DTS Runtime Application
Application app = new Application();
//DTS Package
Package package = app.LoadPackage(packagePath, null);
//Execute and Get the result
DTSExecResult result = package.Execute();
I am making a call to a webservice from asp.net which has the above code. Both the webservice and website have identity impersonation enabled. I have identity enabled in my web.config for this
<identity impersonate="true" userName="MyUserName" password="MyPassword"/>
This problem is only when I am trying to import a Excel file (.xlsx) when I import a .txt file everything is fine. Excel Import blew up in both 32bit and 64bit enviornments.
Help on how to make this to work is greatly appreciated.

You must add this string in you SSiS:
SET ANSI_WARNINGS OFF;

Related

asp.net core executing powershell some commands work while others return result 0

I have the following simple code that works and executes a powershell command in asp.net core website running on my cshtml.cs code behind page
using System.Management.Automation;
public void Execute()
{
using (var ps = PowerShell.Create())
{
ps.AddScript("Get-Date");
var results = ps.Invoke();
foreach (var result in results)
{
string test = result.ToString();
}
}
}
This works i get the current date reported as a string and results variable contains a count of 1.
"7/16/2020 4:38:27 PM"
If i then change it to another command say
ps.AddScript("Get-WmiObject");
or
ps.AddScript("Get-LocalGroupMember -group my_local_group_name");
Then i get no results, results comes back as count of 0 ?? The only thing i can determine is that Get-Date is a single string where as the other commands Get-WmiObject and Get-LocalGroupMember are multiple lines of text in the outputs when i execute them from a normal Powershell window.
my goal is to be able to execute the Get-LocalGroupMember command and get it's output. Is there something else i'm missing or not doing in terms of Powershell commands ? why is it some commands are working and producing output and others are not ?
UPDATE:
So i was getting error in the error stream of the ps object it states
{The 'Get-LocalGroupMember' command was found in the module 'Microsoft.PowerShell.LocalAccounts', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.LocalAccounts'.}
if i open a x86 Powershell window and run the Get-LocalGroupMember cmd it gives me error
Get-LocalGroupMember : The term 'Get-LocalGroupMember' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
running the Get-LocalGroupMember cmd in a regular Powershell window (that is x64) the cmd runs perfect.
My project is set to x64 :( so am failing to understand why asp.net is using what seems to me a 32bit version of powershell. That's what i need i need to be able to execute my powershell cmds as x64 because Get-LocalGroupMember cmd is only available in Powershell x64 .
Please Help ? thanks
so i ended up having to do the following for some reason in order to get certian commands like Get-LocalGroupMember to work, other commands like Get-Date don't require the import, and even though on my system i had execution policy unrestricted, whenever i use c# in asp.net and checked errors on my ps object it was acting like it wasn't and would not let me run a script using AddScript. So i had to be administrator running visual studio and use set-executionpolicy like below, then be able to add the localaccounts module to be able to use Get-LocalGroupMember.. again if i open a x64 Powershell window on the system i can run Get-LocalGroupMember fine. seems c# is doing some weird things with the Powershell shell that it is creating and running in memory. Anyway hopefully this saves someone else time if they run into the same situation.
using (var ps = PowerShell.Create())
{
ps.AddScript("Set-ExecutionPolicy Unrestricted -force");
ps.AddScript("Import-Module Microsoft.PowerShell.LocalAccounts");
ps.AddScript("Get-LocalGroupMember -group your_local_group_name | Out-String");
var results = ps.Invoke();
foreach (var result in results)
{
string test = result.ToString();
TestText = test;
}
}

System.AccessViolationException with Sqlite.Connection.LoadExtension()

I have an old 2005 VB.NET application that requires a Sqlite update for JSON functions.
I have downloaded and installed "sqlite-netFx20-setup-bundle-x86-2005-1.0.109.0.exe". I removed the Reference to the older version, and re-referenced to this new version. I compiled a run the program - all seemed to be okay.
Using an online example for JSON, put the following code behind a TestButton:-
jsondb.SQL = "CREATE TABLE user (name, phone)"
ExecuteSQLiteCommand(jsondb)
jsondb.SQL = "INSERT INTO user (name, phone) values('oz', json('{""""cell"""":""""+491765"""", """"home"""":""""+498973""""}'))"
ExecuteSQLiteCommand(jsondb)
When the "INSERT" is executed, I get "json function not found".
After more research, I found that I had to enable the json extensions with:-
mySQLdb.Connection.Open()
mySQLdb.Connection.EnableExtensions(True)
mySQLdb.Connection.LoadExtension("SQLite.Interop.dll", "sqlite3_json_init")
Initially, the .LoadExtension failed because the "SQLite.Interop.dll" module was not found.
I found a copy of this module in "sqlite-netFx20-binary-Win32-2005-1.0.109.0.zip" and copied it into the Sqlite install directory, and changed the .LoadExension method to:-
mySQLdb.Connection.LoadExtension("C:\Program Files\System.Data.SQLite\2005\bin\SQLite.Interop.dll", "sqlite3_json_init")
Now the .LoadExension method raises an exception "System.AccessViolationException".
Does anyone know how I can resolve this issue?
Thanks in advance.
It seems that because I have the Sqlite Reference attribute CopyLocal=true, then the folder location for System.Data.SQLite.dll and SQLite.Interop.dll need to be the same.
Changing the .LoadExtension to:-
mySQLdb.Connection.LoadExtension(My.Application.Info.DirectoryPath & "\SQLite.Interop.dll", "sqlite3_json_init")
Fixed this.

Read NACHA Formatted File using ChoETL DLL Not Working in SSIS package

I have Used ChoETL.dll and ChoETL.NACHA.dll to read NACHA Formatted file VS2015 C# console and it is working fine.
Created an exe for this console application.
Called the EXE in SSIS package using "Execute Process Task". But it is throwing the below Error.
Message :Failed to parse line to 'ChoETL.NACHA.ChoNACHABatchHeaderRecord' object.
Filename :Sample.txt
StackTrace : at ChoETL.ChoManifoldRecordReader.LoadLine(Tuple`2 pair, Object& rec)
at ChoETL.ChoManifoldRecordReader.<AsEnumerable>d__10.MoveNext()
at ChoETL.ChoManifoldReader.Read()
at ChoETL.NACHA.ChoNACHAReader.<>c__DisplayClass14_0.<GetEnumerator>b__0()
at ChoETL.NACHA.ChoNACHAReader.ChoNACHAEnumeratorWrapper.ChoEnumeratorWrapperInternal`1.MoveNext()
at ChoETL.NACHA.ChoNACHAReader.ChoNACHAEnumeratorWrapper.<BuildEnumerable>d__0`1.MoveNext()
at NachaReader.Program.Main(String[] args
Can any one provide solution to resolve this issue. or suggest any other way to Read NACHA formatted file in SSIS package.

fast export unexplained failure

I have roughly 14 million records that I am attempting to export from a Teradata table to file using a fast export connection object.
There is no size limit for fast export files on our Linux system, and there is 1.2 TB of available space in the target directory.
The session fails, and gives the following errors:
READER_2_1_1 FEXP_87011 Process [16022] exited with status [12]
SDKS_38200 Partition-level [SOURCE_TABLE_NAME]: Plug-in #305400 failed in deinit()
I googled the error message, and found this post:
Here
I followed the recommendations in the port to delete the .out file in the temp directory, delete the files that were partially filled in the target directory, and drop the error table and delete the log file. This did not fix the issue and the session still fails with the same error messages.
Try to use TPT Export plug-in instead. Also you can try to execute this FastExport using bteq scripts directly on your unix environment.

Installing an MSP using Powershell works on the local machine, fails remotely. Why?

I need some Powershell advice.
I need to install an application's MSP update file on multiple Win08r2 servers. If I run these commands locally, within the target machine's PS window, it does exactly what I want it to:
$command = 'msiexec.exe /p "c:\test\My Application Update 01.msp" REBOOTPROMPT=S /qb!'
invoke-wmimethod -path win32_process -name create -argumentlist $command
The file being executed is located on the target machine
If I remotely connect to the machine, and execute the two commands, it opens two x64 msiexec.exe process, and one msiexec.exe *32 process, and just sits there.
If I restart the server, it doesn't show that the update was installed, so I don't think it's a timing thing.
I've tried creating and remotely executing a PS1 file with the two lines, but that seems to do the same thing.
If anyone has advice on getting my MSP update installed remotely, I'd be all ears.
I think I've included all the information I have, but if something is missing, please ask questions, and I'll fill in any blanks.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
My process for this is:
Read a CSV for server name and Administrator password
Create a credential with the password
Create a new session using the machine name and credential
Create a temporary folder to hold my update MSP file
Call a PS1 file that downloads the update file to the target server
>>> Creates a new System.Net.WebClient object
>>> Uses that web client object to download from the source to the location on the target server
Call another PS1 file that applies the patch that was just downloaded –>> This is where I’m having issues.
>>> Set the variable shown above
>>> Execute the file specified in the variable
Close the session to the target server
Move to the next server in the CSV…
If I open a PS window and manually set the variable, then execute it (as shown above in the two lines of code), it works fine. If I create a PS1 file on the target server, containing the same two lines of code, then right click > ‘Run With PowerShell’ it works as expected / desired. If I remotely execute my code in PowerGUI, it returns a block of text that looks like this, then just sits there. RDP’d into the server, the installer never launches. My understanding of the “Return Value” value is that “0″ means the command was successful.
PSComputerName : xx.xx.xx.xx
RunspaceId : bf6f4a39-2338-4996-b75b-bjf5ef01ecaa
PSShowComputerName : True
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 4808
ReturnValue : 0
I even added a line of code between the variable and the execution that creates a text file on the desktop, just to verify I was getting into my ‘executeFile’ file, and that text file does get created. It seems that it’s just not remotely executing my MSP.
Thank you in advance for your assistance!
Catt11.
Here's the strategy I used to embed an msp into a powershell script. It works perfectly for me.
$file = "z:\software\AcrobatUpdate.msp"
$silentArgs = "/passive"
$additionalInstallArgs = ""
Write-Debug "Running msiexec.exe /update $file $silentArgs"
$msiArgs = "/update `"$file`""
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs"
Start-Process -FilePath msiexec -ArgumentList $msiArgs -Wait
You probably don't need to use the variables if you don't want to, you could hardcode the values. I have this set up as a function to which I pass those arguments, but if this is more of a one-shot deal, it might be easier to hard-code the values.
Hope that helps!
using Start-Process for MSP package is not a good practice because some update package lockdown powershell libs and so you must use WMI call

Resources