|
|
Assuming you've define an appropriate user variable in the ssis package, look at this:
Use SSIS Variables and Parameters in a Script Task - TechNet Articles - United States (English) - TechNet Wiki[^]
Once you get the current value of the variable, you can simply do this to remove all the "/" characters:
myVariable = myVariable.Replace("/", "");
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
https://ibb.co/iZmhUn
Dear all I can not handle this. Can you help me?
Thanks
Form1 has combobox and a button to open Form 2
Form 2 has textbox and a button to OK&Exit
I want to add text value from Form2 to Form1 combobox.
|
|
|
|
|
|
The library of L-Card release similar COM interface. The function CreateLInstance return pointer for class C++.
In C++ is
pModule = static_cast<ILE140 *>(CreateLInstance("e140"));
where
struct ILE140 : public ILUSBBASE
{
virtual BOOL WINAPI GET_ADC_PARS(ADC_PARS_E140 * const AdcPars) = 0;
virtual BOOL WINAPI SET_ADC_PARS(ADC_PARS_E140 * const AdcPars) = 0;
virtual BOOL WINAPI START_ADC(void) = 0;
.......
}
and
struct ILUSBBASE
{
virtual BOOL WINAPI OpenLDevice(WORD VirtualSlot) = 0;
virtual BOOL WINAPI CloseLDevice(void) = 0;
virtual BOOL WINAPI ReleaseLInstance(void) = 0;
virtual HANDLE WINAPI GetModuleHandle(void) = 0;
virtual BOOL WINAPI GetModuleName(PCHAR const ModuleName) = 0;
virtual BOOL WINAPI GetUsbSpeed(BYTE * const UsbSpeed) = 0;
virtual BOOL WINAPI GetLastErrorInfo(LAST_ERROR_INFO_LUSBAPI * const LastErrorInfo) = 0;
};
How can this be implemented on C#?
Function CreateLInstance can declarated as
[DllImport(@"Lusbapi.dll")]
static extern IntPtr CreateLInstance(string devname);
But how to declare an ILE140 class and convert a type IntPtr to ILE140?
|
|
|
|
|
Does anyone have a SIMPLE implementation of WeakEventHandler?
I've been Googling but all I see to find is the interfaces or some REALLLLY long complicated code.
I did find this MSDN page but the code doesn't compile:
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 26-Mar-18 16:53pm.
|
|
|
|
|
Are you looking to write your own WeakEventHandler implementation or could you just use one of the pre-built ones, listed in the inheritance tree, here[^]?
The code probably doesn't compile because the example is not meant as a copy'n'paste example. You have to replace certain works in the source with either your own implementations or with interface names of the event type you're looks for. You'd probably even have to extend WeakEventManager with your own implementations of certain methods, depending on what you're doing.
There are no "simple" examples of this thing. About the only thing I could suggest is looking at the .NET Reference Source for a similar implementation of what you're trying to do and using that as a framework to write your own code. For example, the source for PropertyChangedEventManager can be found here[^].
modified 27-Mar-18 10:48am.
|
|
|
|
|
I'm looking to create an event aggregator and it seemed like a weak even manager is the way to go. I don't know anything about it so I'm looking for a simple example I can study.
For example, I know that Prism uses one, but Prism is a beast. WAY too over-engineered.
Again, I just want to put together something simple for handling events in my app.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
"an event aggregator"
You're going to have to explain what that means, exactly.
|
|
|
|
|
Event Aggregator
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
OK, I see what you're getting at. Unfortunately, I've never seen a "simple" implementation of this. What I've done in the past is something very similar to the implementation found in the Prism library. The latest source for the EventAggregator in there can be found here[^].
|
|
|
|
|
Thanks. I'll take a look
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
void FillCombo()
{
try
{
DateTime MONDAY = DateTime.Now;
DateTime FRIDAY = DateTime.Now.AddDays(5);
string query = "SELECT orderID,FinalDate,StartDate FROM Tbl_Auftrag Where [StartDate] BETWEEN '" + MONDAY + "' AND '" + FRIDAY + "' AND [FinalDate] BETWEEN '" + MONDAY + "' AND '" + FRIDAY + "'";
con.Open();
SqlCommand cmdDataBase = new SqlCommand(query, con);
SqlDataReader rdr = cmdDataBase.ExecuteReader();
while (rdr.Read())
{
String sName = rdr["orderID"].ToString();
listBox1Montag.Items.Add(sName);
listBox2Dienstag.Items.Add(sName);
listBox3Mittwoch.Items.Add(sName);
listBox4Donnerstag.Items.Add(sName);
listBox5Freitag.Items.Add(sName);
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}
Hello ,
I have a problem and I dont know how to solve it. With this code I can see all orderID's between today and in the next five days. But what if for example orderID: 234324 , StartDate = 26.03.2018, FinalDate = 27.03.2018 exists.... I should only see it in the listbox Monday and Tuesday. But its everywhere ... -.-
I know why... but not how to change that :/
maybe someone can help me?
|
|
|
|
|
Start by not doing that! Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
When you concatenate strings, you cause problems because SQL receives commands like:
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood' The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable; Which SQL sees as three separate commands:
SELECT * FROM MyTable WHERE StreetAddress = 'x'; A perfectly valid SELECT
DROP TABLE MyTable; A perfectly valid "delete the table" command
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.
So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?
In this specific case it doesn't expose you to SQL Injection, but it does bring up a different probable problem which may be causing what you have found. When you concatenate strings, you cause an implicit ToString on your DateTime objects which will convert them using the default culture for the computer that is running that code. In most production systems the SQL server is a separate computer (which may not even be in the same country, let alone LAN segment) and that computer may well be configured for a different default date format. So when SQL parse your string, it can very, very easily convert it wrong: you supply dd/MM/yyyy and it reads MM/dd/yyyy for example.
So go through the whole of your app and fix it: remove all string concatenations, replace them with parameterized queries, and see if your problem disappears at the same time...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Once you fix your concatenated SQL, you need to fix your reader loop; there is nothing to differentiate what the start and stop dates are
while (rdr.Read()) {
String sName = rdr["orderID"].ToString();
listBox1Montag.Items.Add(sName);
listBox2Dienstag.Items.Add(sName);
listBox3Mittwoch.Items.Add(sName);
listBox4Donnerstag.Items.Add(sName);
listBox5Freitag.Items.Add(sName);
}
What you need to do is to enumerate through the rows and check to see if the start/finish dates align with a particular day
while (rdr.Read()) {
String sName = rdr["orderID"].ToString();
DateTime StartDate = Convert.ToDateTime(rdr["DateField"]).ToString("dd/MM/yyyy");
DateTime FinalDate = Convert.ToDateTime(rdr["FinalDate"]).ToString("dd/MM/yyyy");
if ((StartDate <= MONDAY) && (FinalDate >= MONDAY)) { listBox1Montag.Items.Add(sName); }
if ((StartDate <= FRIDAY) && (FinalDate >= FRIDAY)) { listBox5Freitag.Items.Add(sName); }
}
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
Dear all,
I have a folder that including input files (generally 20 to 30 files)
I want to order names when the form loaded on 1st column of listbox.
Thanks
|
|
|
|
|
|
The efficient way to do it is to sort before you add the items:
string[] files = Directory.GetFiles(@"D:\Test Data", "*.*", SearchOption.AllDirectories);
string[] sortedFiles = files.OrderBy(f => Path.GetFileNameWithoutExtension(f)).ToArray();
myListBox.Items.AddRange(sortedFiles);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In your example, you're specifying all directories. Wouldn't you do this instead:
string[] files = Directory.GetFiles(@"D:\Test Data", "*.*", SearchOption.AllDirectories)
.OrderBy(f => Path.Getdirectory(f))
.ThenBy(f => Path.GetFileNameWithoutExtension(f))
.ToArray();
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
In the real world? Probably.
It's just an example - I have no idea what he really wants to sort by, the info is a bit sparse!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Eg. File names in folder names ( bb1.txt, bb2.txt, cc1.txt, cc2.txt ....)
When I load the window I want to see txt files names in different rows, sorted on 1 st column.
A
bb1
bb2
cc1
cc2
.
.
.
I think you get the point now
|
|
|
|
|
Nope, still makes no sense! Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. And I have no idea what folders you have, or what you are trying to do with them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In Griff's original answer, change the second parameter in the call to Directory.GetFiles from "*.*" to "*.txt"
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Hi,
I have a table in SQL like so
UId Class
1 Apple
2 Apple
3 Apple
3a Apple
4 Orange
4a Orange
4b Orange
5 Orange
I am trying to get the min and max of the UId column for each class as below.
1 - 3 Apple
4 - 5 Orange
Is it possible to do so, as the UId is varchar.
Thanks
modified 23-Mar-18 23:41pm.
|
|
|
|
|
sunsher wrote: Is it possible to do so, as the UId is varchar.
Yes, but ... it's frankly pretty nasty, and going to make for a complicated query.
If you want data that you can treat as numeric - and you will need to use it for numerics at some point, or your sort order will be completely wrong - I'd strongly suggest that you change the column, and split it into two parts: a numeric prefix, and an alphabetic suffix. That way, you can ignore your suffix when trying to work with numbers, and combine the columns to a strign when you want to work with the "original value".
Then it's trivial:
SELECT MIN(numericBit), MAX(numericBit), Class
FROM MyTable
GROUP BY Class But trying to do that with string based data that may contain alphabetic suffixes? Nasty, nasty code.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|