|
I checked it. The error occurs in the first loop. Of course, I'm using advanced DataGridView (because of its filter capability). Maybe, I should use native DGV instead.
|
|
|
|
|
That would explain the difference between your code and mine ...
You can filter standard DGVs using a binding source - didn't we tell you that a week ago or so?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm going to change them with standard DGV.
|
|
|
|
|
There was an update to advanced DataGridView. I updated it and the issue solved. The filter function also has very rapid response like Excel.
|
|
|
|
|
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
i'll try to read a cwe xml file. The problem is i have not good solution read it in a good way out
That is a xml file
CWE - Downloads[]
I'll find for example ID "1004" and will read all Items behind.
When i will read value from <background_detail> i find not a way to read this out
XElement xelement = XElement.Load(@".\cwec_v4.4.xml");
var value = from cwe in xelement.Elements().Elements()
where (string)cwe.Attribute("ID") == "1004"
select cwe;
foreach (XElement xEle in value)
{
Console.WriteLine(xEle.Value);
}
var result = xelement.Elements().Elements()
.Where(x => x.Attribute("ID").Value == "1004")
.Elements().Where(x => x.Name == "Background_Details")
.Elements().Where(x => x.Name == "Background_Detail")
.Select(x => x.Value);
Have somebody experience and can help me
modified 8-Jun-21 16:20pm.
|
|
|
|
|
|
The XML document has a default namespace. You need to use that to select elements by name:
var document = XDocument.Load(@".\cwec_v4.4.xml");
var ns = document.Root.Name.Namespace;
int idToFind = 1004;
string detail = doc.Descendants(ns + "Weakness")
.Where(el => (int)el.Attribute("ID") == idToFind)
.Elements(ns + "Background_Details")
.Elements(ns + "Background_Detail")
.Select(el => el.Value)
.FirstOrDefault(); If you want to read multiple values from a single weakness, you'll want to cache the Weakness element:
XElement weakness = document.Descendants(ns + "Weakness")
.FirstOrDefault(el => (int)el.Attribute("ID") == idToFind);
if (weakness != null)
{
string description = (string)weakness.Elements(ns + "Description");
string detail = (string)weakness.Element(ns + "Background_Details").Element(ns + "Background_Detail");
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks a lot, it works wonderfully 
|
|
|
|
|
Hi,
I want to make a managerial app using Xamarin. Is there any free SQL Server on the cloud which I can use in Visual Studio during app development (and as a database source for my app)?
I just only need to have a small amount of storage. My clients will be less than 100.
|
|
|
|
|
There are some - normally associated with free websites - but ... would I use one? Not on your Nellie!
They are free for a reason: very limited storage, very poor or non-existent / expensive tech support, availability and speed can be very low. You really do get what you pay for!
"100 clients" doesn't necessarily mean "low storage volume", it depends on the number of clients and the space each will use. Add to that, that space is not the same as bandwidth / processing time: responses need to be timely as well as small!
And these apply to the website and the DB - so unless you really don't care for security, uptime, or space, I'd pay for it. There are good one available cheap, but use Google to find one i your country if possible - it makes support much easier and (hopefully) quicker.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Azure SQL Service has a trial period for use. Is it possible to put an SQLite database file in the cloud and use the cloud IP address for reading/writing database on clients' devices?
|
|
|
|
|
That is a spectacularly bad idea, and most installations of SQL Server will not allow it - to do that you have to expose the whole DB server to the internet along with all the DBs it handles, with all the security problems that opens up!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I recently ran into a problem where I'm running a C# program on the Windows command line and the % character is breaking things. So it's like runthisprogram.exe -variables -outputname "I am a filename 100%.mkv".
The % in the above path when passed to the application errors. They say I have to escape the % to get it to work and they are correct, but if
I am a filename 100%.mkv
is in a variable, how do I dynamically search the contents and if there is a % replace it with %%
Thanks.
|
|
|
|
|
How about
myString = myString.Replace("%", "%%");
|
|
|
|
|
|
To add to what Dave has said, that sounds like they are giving you the runaround: unless you are creating a batch or powershell file from your string then the '%' character has no special significance in either a command line to an application, or a filename. You can happily execute a C# program and hand it a single '%' as part of a file name:
using System;
namespace OneOffConsole
{
class Program
{
static void Main(string[] args)
{
foreach (string s in args)
{
Console.WriteLine(s);
}
}
}
}
Microsoft Windows [Version 10.0.19043.985]
(c) Microsoft Corporation. All rights reserved.
C:\Users\PaulG>cd "D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug"
C:\Users\PaulG>D:
D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>oneoffconsole -variables -outputname "I am a filename 100%.mkv"
-variables
-outputname
I am a filename 100%.mkv
D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>dir >"x 100%.txt"
D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>type "x 100%.txt"
Volume in drive D is GriffData
Volume Serial Number is 4CA5-2F85
Directory of D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug
08/06/2021 06:39 <DIR> .
08/06/2021 06:39 <DIR> ..
20/06/2019 17:39 4,079,616 itextsharp.dll
20/06/2019 17:39 3,180,097 itextsharp.xml
20/06/2019 17:39 169,984 itextsharp.xmlworker.dll
08/06/2021 06:35 4,608 OneOffConsole.exe
25/06/2019 06:47 189 OneOffConsole.exe.config
08/06/2021 06:35 19,968 OneOffConsole.pdb
08/06/2021 06:39 0 x 100%.txt
7 File(s) 7,454,462 bytes
2 Dir(s) 805,619,617,792 bytes free
D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>
But that's worrying to me: because '%' isn't a special character in Windows, or C# - but it is in SQL, and only when passing strings to a database without using parameterised queries.
And that's very dangerous as it leaves an application wide open to something called "Sql Injection" which can destroy your entire database. Applications should always use Parameterized queries instead.
When you pass strings directly, 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.
I'd suggest that you ask the developers why the '%' character is causing problems within a well-formed and quoted filename, and ask to see the code that it affects.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Joseline Riker wrote: The % in the above path when passed to the application errors. But you have not explained what error or where it occurs. As it stands using the % character in a filename is perfectly legal.
|
|
|
|
|
Try
I am a filename/Am I? .sav
File names are that; they should adhere to the naming rules, and aren't intended as a label.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
note: this is not about AOP, IL weaving, Furty, PostSharp, etc., although those facilities are related to this discussion.
Context: in WinForms both these notification methods have, imho, very limited uses.
Do you use these mechanisms more frequently in WPF ? Are they valuable to you ? Essential/integral in MVVM ?
Have you ever developed your own notification-with-cancellation mechanism (i have, for WinForms).
0) there's an excellent overview of how INotifyPropertyChanged can be used in different C# versions by SO's resident genius, Marc Gravell: [^]
1) INotifyPropertyChanging has no cancel mechanism ... unless you consider throwing an error in some context you have no control over sweet-smelling code According to PostSharp docs: "INotifyPropertyChanging interface is not portable (in Xamarin, it is even a part of a different namespace)."
2) INotifyPropertyChanged is just post-facto notification. There does appear to be a special benefit in using it with SQL and Linq: [^] ... i've never played with that.
Of course, you could trigger update of a binding connection. And, using Caller Information Attributes is easy in a Notify* changed handler ... imho, those attributes are of very limited value.
3) through "heroic" programming, you can create custom EventArgs that inherit from the INotify* versions and extend them to implement cancellation. however, in your subscribing objects' handlers you will have to cast the incoming args to their extended form.
there's an outstanding 2 article series here on CP from 2007: [^] that shows this kind of EventArgs extending as a way to get cancellation.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 7-Jun-21 22:00pm.
|
|
|
|
|
BillWoodruff wrote: Do you use these mechanisms more frequently in WPF ? Hardly done any WPF.
BillWoodruff wrote: 1) INotifyPropertyChanging has no cancel mechanism ... unless you consider throwing an error in some context you have no control over sweet-smelling code According to PostSharp docs: "INotifyPropertyChanging interface is not portable (in Xamarin, it is even a part of a different namespace)." Cancelling an update would be exceptional, and not the rule. Never tried Xamarin; Mono is enough for me.
BillWoodruff wrote: 2) INotifyPropertyChanged is just post-facto notification. There does appear to be a special benefit in using it with SQL and Linq: [^] ... i've never played with that.
Of course, you could trigger update of a binding connection. And, using Caller Information Attributes is easy in a Notify* changed handler ... imho, those attributes are of very limited value. Dunno, never tried; I like close control over my queries.
BillWoodruff wrote: 3) through "heroic" programming, you can create custom EventArgs that inherit from the INotify* versions and extend them to implement cancellation. however, in your subscribing objects' handlers you will have to cast the incoming args to their extended form. Why would you, if it is already there? Exceptions aren't that expensive.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks for you thoughts ! A major use of cancellation+notify code is to implement external validation on a per instance basis for your class. The multi-cast event driven technique enables external subscribers to define the validation code and/or the actions taken if validation passes or fails.
imho, locating responsibility for validation/data integrity outside the class can be seen as a "separation of concerns" strategy.
Of course, you could implement validation as a singleton within the class, so all external consumers are using the same validation.Eddy Vluggen wrote: Cancelling an update would be exceptional, Every time you use some validation method, potentially, cancelling an update can occur.Eddy Vluggen wrote: Exceptions aren't that expensive. When you allow external clients to inject executable code, potentially any of those clients could crash their code by throwing an error: meanwhile, back at the ranch, the calling class' code is waiting ...
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 8-Jun-21 20:37pm.
|
|
|
|
|
BillWoodruff wrote: Every time you use some validation method, potentially, cancelling an update can occur. Yes, but that'd be exceptionally, not the rule.
BillWoodruff wrote: When you allow external clients to inject executable code, potentially any of those clients could crash their code by throwing an error: If you allow external clients that, you got a bigger problem on your hands and them throwing an exception is not the most dramatical consideration.
During classes, we considered all humans interacting with the systen to be potentially evil. It kinda sticked; you prepare for the worst.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I'll add to Eddy's information, except as applies to WPF.
This is probably the simplest view, but I use INotifyPropertyChanged for program properties that are bound to screen controls. When the program is changing the value rather than the user it lets you update the value whenever you like, and the screen updates naturally. The benefit of doing things this way is that the relationship between the property and the control is defined by the binding, so that it works the same everywhere. You don't have to worry about changing update code wherever you change the value.
I'll admit I don't particularly like the binding mechanism. It's complex and expressing bindings directly in XAML can be an exercise in frustration. I set most of my bindings in the C# code-behind because the XAML syntax is so awkward.
Software Zen: delete this;
|
|
|
|
|
Thanks, Gary, that's the type of reply i hoped i'd get !
i never explored binding in Win Forms beyond DataSet to Grid. List to ComboBox.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Glad to be of help.
In its way binding is very useful. It lets you handle conversions between the on-screen depiction and your internal representation consistently. For data entry you can add your own validation rules and integrity checks.
One caveat to my statements. I don't do data base applications so I'm not familiar with more elaborate bindings, say between a data base table and a grid control. I imagine there are quite a few articles here on CP and examples in the wild that can help if you need it.
Software Zen: delete this;
|
|
|
|
|