How to pass text in configuration file with a call to parameter - ssis

I have a package that sends emails, I have it set with a configuration file so I can pass a parameter with the addresses, attachments, etc. that I want to use, one of these parameters is the Message_source:
in which I pass the content of the email.
my problem comes in that I want to pass formatted text and a dynamic field (date).
how can I do this so I can send something like this:
<Configuration ConfiguredType="Property" Path="\Package.Variables[User::Email_Content].Properties[Value]" ValueType="String">
<ConfiguredValue>here I want to pass a date, here is the date: #Date</ConfiguredValue>
</Configuration>
so I can generate something like this:
here I want to pass a date,
here is the date: 05-01-2023
I know that I can parse the date with:
RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2) + "-" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE())
however adding this to the config file right away doesn't work.

If it's going to work, I think you're going to add in a few more levels of indirection.
What you want is to have an Expression as the content of a variable. It's happy to assign your string to the Value property but what is being sent is not the evaluated #Date but the literal characters # D A T E
<Configuration ConfiguredType="Property"
Path="\Package.Variables[User::Email_Content].Properties[Expression]" ValueType="String">
<ConfiguredValue>"I want to pass a date, here is the date: " + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2) + "-" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE())</ConfiguredValue>
</Configuration>
The same rules will apply with string building and all that so if you want to have it look like "I want to pass a date, here is the date: #Date" then you need to build out a valid expression. I'd create a Variable named Test and plug away until I get the syntax correct and then slap that, carefully, into your XML/dtsconfig
"I want to pass a date, here is the date: "
+ RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2)
+ "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2)
+ "-" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE())
Finally, if that isn't working then ensure that #[User::Email_Content] has the EvaluateAsExpression property set to True

Related

SSIS Foreach loop adding extra date and extension to one file name

When my package runs the Foreach loop container to rename 4 excel files it adds the date to each files and then adds an extra date and extension to the 1 file in the folder.
Example: Contracts_010120.xlsx_010120.xlsx.
REPLACE( #[User::Copy_Temp_M_To_J] ,"_TEMP.xlsx", "")
+ "_"+Right("0"+ (DT_WSTR ,2) DATEPART("mm",GetDate()),2)
+ RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2)
+ RIGHT("0" + (DT_WSTR,4)DATEPART("yyyy",GetDate()) ,2)
+ ".xlsx"
It's just doing it to one file in the folder.

Appendheader needs to append string, variable and then string again

Hopefully this is an easy one for someone out there. I need to append a long command that has strings and variables in it.
this->AppendHeader("Content-Range", "bytes " + offset "-" + (offset + part_size - 1) "/" + file_size);
This is not acceptable in C++. How can I format the above so the Header looks like
Content-Range: bytes 0-19/40
(just a fyi - offset is 0, part_size is 20 and file_size is 40)

SSIS Filename variable with wildcards

I am looking at creating a SSIS package that copies the latest file from a specific directory. There are multiple files output to the directory each day and each gets date and time stamped in the file name
FLATFILE_20150909_130801.txt
FLATFILE_20150909_230508.txt
I am only interested in the latest file during the day. Which will always have the same prefix 23 . I’ve written the expression as
"\\\\DESTINATION\\FLATFILE"+ "_"+ (DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2) + "_"+ "23"+ "****"+ ".sqb"
Which returns FLATFILE_20150909_23****.txt
Is there any way to assign wildcards to the characters in the string **** so it ignores these??

SSRS expression to get first character from string

I am having a field with string values as "First Middle Last" and i want to show the initial characters from this string as "FML"
how can i do it in terms of ssrs expression ?
Assuming the field MyString always has 3 words the following will find the first character of the First, Second and Last words. This admittedly doesn't handle instances where there are more or less than 3 words, but hopefully should get you started if you require more finesse.
=Left(Fields!MyString.Value, 1) + " " +
Left(Mid(Fields!MyString.Value, InStr(Fields!MyString.Value, " ") + 1), 1) + " " +
Left(Mid(Fields!MyString.Value, InStrRev(Fields!MyString.Value, " ") + 1), 1)
Edit
To cope with the possiblity of only two words (as suggested in the commetns below) a check for the index of the spaces could be used to ensure that they are not the same, and thus 3 words exist. This would make the code as follows
=Left(Fields!MyString.Value, 1) + " " +
Left(Mid(Fields!MyString.Value, InStr(Fields!MyString.Value, " ") + 1), 1) +
iif(InStrRev(Fields!MyString.Value, " ") > InStr(Fields!MyString.Value, " "),
" " + Left(Mid(Fields!MyString.Value, InStrRev(Fields!MyString.Value, " ") + 1), 1),
"")

C++ Builder XE, dbExpress with MySQL 5.x

I'm trying to get the dbExpress TSQLConnection to work with a MySQL 5.x server.
I have searched the net but not found any helpfull instruction for C++ Builder XE.
I downloaded the dbxopenmysql50.dll driver from just software solutions and followed the instructions on their site.
I downloaded the libmysql.dll from mysql and put the dll's in the bin folder of C++ Builder XE and edited the dbxdrivers.ini to use the new DLLs.
In the IDE when I tset the TSQLConnection property connected to true, the dbxopenmysql50.dll crash with Access Violation in address bla bla bla...
I don't care about my current setup, but is there ANYONE that have this working?
How did you make it work? Please direct me where to download free working DLLs for dbExpress with MySQL 5.x
Here is some more error information:
"Access violation in address 10395D99 in module 'dbxopenmysql50.dll'. Read of
address 0275C8D".
Detailed dump from C++ Builder XE Error dialog.
(00004D99){dbxopenmysql50.dll} [10395D99]
[50037560]{rtl150.bpl } System.#FreeMem (Line 3768, "System.pas" + 20) + $0
[500415CF]{rtl150.bpl } System.LocaleCharsFromUnicode (Line 29632, "System.pas" + 1) + $17
[50052A6C]{rtl150.bpl } SysUtils.StrPosLen (Line 9617, "SysUtils.pas" + 8) + $13
[5003D9B4]{rtl150.bpl } System.#UStrDelete (Line 22863, "System.pas" + 10) + $5
[50037560]{rtl150.bpl } System.#FreeMem (Line 3768, "System.pas" + 20) + $0
[5003C0B0]{rtl150.bpl } System.#UStrClr (Line 16968, "System.pas" + 14) + $0
[500A0F89]{rtl150.bpl } Classes.TStrings.GetValueFromIndex (Line 5756, "Classes.pas" + 12) + $10
[51D1B35B]{DbxCommonDriver150.bpl} Dbxdynalink.TDBXDynalinkDriverCommonLoader.LoadDriverLibraryAndMethodTable + $E3
[51D1AFE9]{DbxCommonDriver150.bpl} Dbxdynalink.TDBXDynalinkDriver.LoadDriver + $35
[51D1DCD8]{DbxCommonDriver150.bpl} Dbxdynalinknative.TDBXDynalinkDriverNative.CreateConnection + $C
[51CF0C19]{DbxCommonDriver150.bpl} Dbxcommon.TDBXDelegateDriver.CreateConnection + $5
[51CF6666]{DbxCommonDriver150.bpl} Dbxcommon.TDBXConnectionBuilder.CreateConnection + $B6
[51CE7B5C]{DbxCommonDriver150.bpl} Dbxcommon.TDBXConnectionFactory.GetConnection + $E8
[51CE7A6D]{DbxCommonDriver150.bpl} Dbxcommon.TDBXConnectionFactory.GetConnection + $5
[50FFC77F]{dbexpress150.bpl} SqlExpr.TSQLConnection.DoConnect (Line 2537, "SqlExpr.pas" + 52) + $5
[5070E10D]{dbrtl150.bpl} DB.TCustomConnection.SetConnected (Line 3167, "DB.pas" + 8) + $4
[50089A3E]{rtl150.bpl } TypInfo.SetOrdProp (Line 1791, "TypInfo.pas" + 28) + $0
[2105A0A6]{designide150.bpl} DesignEditors.TPropertyEditor.SetOrdValue (Line 841, "DesignEditors.pas" + 2) + $E
[2109E55B]{designide150.bpl} VCLEditors.TBooleanProperty.MouseUp (Line 1840, "VCLEditors.pas" + 5) + $10
[21194BD9]{vclide150.bpl} PropBox.TCustomPropListBox.ItemMouseUp (Line 1625, "PropBox.pas" + 16) + $1B
[21194DCF]{vclide150.bpl} PropBox.TCustomPropListBox.MouseUp (Line 1690, "PropBox.pas" + 1) + $D
[5027E90C]{vcl150.bpl } Controls.TControl.DoMouseUp (Line 7318, "Controls.pas" + 2) + $28
[5027E988]{vcl150.bpl } Controls.TControl.WMLButtonUp (Line 7331, "Controls.pas" + 9) + $6
[2119A4C0]{vclide150.bpl} IDEInspListBox.TInspListBox.WMLButtonUp (Line 1631, "IDEInspListBox.pas" + 3) + $4
[5027DF6C]{vcl150.bpl } Controls.TControl.WndProc (Line 7074, "Controls.pas" + 91) + $6
[06D19928]{AQtime7BDS8.bpl} Aqsyncedit.TaqEditPainter.HasHintInfo + $9B8
[502820C3]{vcl150.bpl } Controls.TWinControl.IsControlMouseMsg (Line 9608, "Controls.pas" + 1) + $9
[50282830]{vcl150.bpl } Controls.TWinControl.WndProc (Line 9831, "Controls.pas" + 144) + $6
[502B8409]{vcl150.bpl } StdCtrls.TCustomListBox.WndProc (Line 6217, "StdCtrls.pas" + 54) + $6
[50281ED0]{vcl150.bpl } Controls.TWinControl.MainWndProc (Line 9552, "Controls.pas" + 3) + $6
[500AFA64]{rtl150.bpl } Classes.StdWndProc (Line 13491, "Classes.pas" + 8) + $0
[50358AF7]{vcl150.bpl } Forms.TApplication.ProcessMessage (Line 9760, "Forms.pas" + 23) + $1
[50358B3A]{vcl150.bpl } Forms.TApplication.HandleMessage (Line 9790, "Forms.pas" + 1) + $4
[50358E65]{vcl150.bpl } Forms.TApplication.Run (Line 9927, "Forms.pas" + 26) + $3
Thanks in advance.
I have DBExpress working fine with MySQL 5.1 in Delphi 2010.
So try putting the libMySQL.DLL in your exe directory may help, as this is first place it will look.
check if you need any other DLL's (I needed dbxmys.dll as well , but working with MySQL)
Set the Params to suit your MySQL server - (Localhost, MyDBName, MyUSerName MyPasswd) then try and connect in the IDE. It works for me!
Chris