|
What type of app are you writing, which version of .NET or the .NET Framework are you writing this code against, and are you exposing any components in your app to COM?
|
|
|
|
|
I'm writing a program to control incomes and expenses of a small company. .NET Framework version 4.8.04084. Microsoft Visual Studio Community 2022 Version 17.2.6
Is this what you wanted?
|
|
|
|
|
OK, so you're writing either a Windows Forms app, or WPF, for some accounting function.
You have no reason at all to be saving anything to HKEY_LOCAL_MACHINE. Follow the advice of Griff.
As for the Guid of the app, you really have no use for it so why are you interested in it?
|
|
|
|
|
Hi, Dave.
I changed my approach. Now I get a special folder path and will use it to store a text file containing the installation folder of my app. The command is:
string caminho = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData).ToString();
I think it will solve my problem.
Thanks for your help and interest!
|
|
|
|
|
GetFolderPath always returns a string, so why are you calling .ToString() on a string?
|
|
|
|
|
You do not need to store that. You can get that info at runtime.
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.
|
|
|
|
|
Hi, Eddy.
How can I obtain the installation folder of an application? Note that I need it from another application, not the one running at this moment.
Thanks.
|
|
|
|
|
And it's prolly not an application that you launched, so it is a running app that you did not launch?
Does the app have a windows handle? Then you can get the executables location.
https://www.autohotkey.com/boards/viewtopic.php?t=69925[^]
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.
|
|
|
|
|
hello everyone, I'm a young developer c#, I'm using dapper for data manipulation, I have a database on which making a particular query I get 100K + 18 rows that will have to be exported to excel . The problem lies in the fact that, to get the results, it takes almost 12 minutes....to have array_channel_list[i],Can you speed it up in some way ?thank you very much! (sorry for my bad english)
<pre>
List<string> query = new List<string>();
List<EntityFramework.Channels>[] array_channel_list = new List<EntityFramework.Channels>[dim];
using (var conn = new SqlConnection(connection))
{
for (int i = 0; i < dim; i++)
{
query.Add("SELECT ID, matricola, disegno, descrizione, nodeid, result, coppia, angolo, prgnr, prgname, date, NomeFile, lastcmd, laststeprow, laststepcolumn, qualitycode, rootobj_ID FROM dbo.Channels where rootobj_ID IN (" + string.Join(",", array_id[i]) + ") ORDER BY ID");
try
{
array_channel_list[i] = conn.Query<EntityFramework.Channels>(query[i], commandTimeout: queryTimeoutInSeconds,buffered:false).ToList();
}
catch (SqlException error)
{
Console.WriteLine("Errore: " + error.ToString());
}
}
}
|
|
|
|
|
Without access to your DB and any idea what the query results look like, we can't really help much - except to say that multiple SELECT queries aren't a particularly fast way to do it: you may get significant improvements by issuing a single request and post-processing the data locally in memory.
I'd start by profiling the code to find out where the time is being taken: if nothing else, the Stopwatch class should be able to give you a good idea where your bottle necks are, though you may have to "break up" that code to start getting any meaningful results as method chaining makes any profiling pretty difficult.
"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!
|
|
|
|
|
Antennista Televes wrote: query.Add("SELECT ID, matricola, disegno, descrizione, nodeid, result, coppia, angolo, prgnr, prgname, date, NomeFile, lastcmd, laststeprow, laststepcolumn, qualitycode, rootobj_ID FROM dbo.Channels where rootobj_ID IN (" + string.Join(",", array_id[i]) + ") ORDER BY ID");
Don't do it like that!
Your code is almost certainly vulnerable to SQL Injection[^]. NEVER use string concatenation/interpolation to build a SQL query. ALWAYS use a parameterized query.
Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
Beyond that, your question is not clear. Your code mentions Entity Framework, but you seem to be using a method from Dapper[^]. You haven't explained what array_id contains. You haven't explained why you're loading an array of List<T> instances. And you don't appear to have profiled your code to find out which part is slow.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You've got dates and names in your query; and no grouping / summing or range checking.
It's basically a "data dump" and not a meaningful query in any sense of the word.
You need to ask yourself at some point: Why am I running this query? Why am I not using a stored procedure?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I wish to write a program like Quicken, only better. I am having trouble finding a control that looks like a check register. Does anyone know of such an animal?
Thanks in advance!
|
|
|
|
|
What the heck is a "check register"? Without using Quicken - which I don't - we have no idea what you are after.
And to be honest, copying the "look and feel" of an app but making it "only better" is probably not a good idea - it's asking for corporate lawyers to start writing you some very unpleasant letters ... in much the same way that coming out with a new soft drink in a red can called "Caca Cola" would .
I'd suggest that you think about what the original does well, work out ways that can be done better, and then design your own unique UI to makes the whole task easier for the user - then start designing the new app.
"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!
|
|
|
|
|
For such a specialized application, you're most likely not going to find such an animal.
You'll probably have to write your own control for that.
|
|
|
|
|
I am wondering if someone or some company already has. I do not know how to write a control, and I really don't want to take the time to learn it right now.
I thank you very much for your input! 
|
|
|
|
|
It would benefit you greatly to learn how to write controls. This will come up a lot more often then you think.
|
|
|
|
|
Quote: I do not know how to write a control, and I really don't want to take the time to learn it right now.
So ... your app is going to be largely bits of stuff you don't understand slammed together with a lot of "I hope it works" glue?
When something goes wrong, how do you propose to work out where the problem is, let alone how to fix it?
"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!
|
|
|
|
|
"Check Register" is an "application"; and more than just one control. It includes check runs / printing and bank reconciliation. Controls are building blocks; views are composed of controls. One "view" might be outstanding checks; one aspect of a check register (which is starting to look like the infamous "data grid").
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
That's just it. I need a datagridview-like thing. I tried using datagridview, but it has too many bugs, and is too hard to understand. I can take care of all of the data manipulation. It's just the GUI that I am struggling with now.
|
|
|
|
|
Member 15750670 wrote: I tried using datagridview, but it has too many bugs
Like what? I've been using it for well over a decade and it hasn't shown any bugs in all that time.
Member 15750670 wrote: I tried using datagridview ... is too hard to understand
I suspect that the "bugs" comment and this are related by a common factor: you don't know how to use a DataGridView.
Maybe this wold help: C# DataGridView Tutorial[^]
"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!
|
|
|
|
|
Yes, part of it is exactly that: I don't know how to use a DataGridView. I have not found enough examples (that's how *I* learn). I DID find (and document) some squirrelly behavior in one program that I have since discarded.
|
|
|
|
|
Member 15750670 wrote: I have not found enough examples (that's how *I* learn)
Then stop trying to learn like that: you don't learn properly by looking at existing code because code doesn't tell you *why* it is like it is: what was tried, what was rejected, why was it rejected.
Development isn't a "memory exercise" like learning a language, or chemistry, or biology - it's a skill, and the only way to learn a skill is to think and try. You can watch as much of the Tour de France as you like, it won't teach you to ride a bicycle!
"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 don't need to know "why" until I can get it to work the way I want. My goals are clear. I am an accomplished mainframe professional. I learned most of what I know from examples, not by poring through reams of unintelligible documentation. Now I am embarking on a hobby of learning C# and .Net. I appreciate the advice of people who have been there.
You are wrong. Watching the Tour de France can give you a lot of insight to riding a bicycle in a crowd. I believe you are a little narrow-minded to think that everyone learns the way you do (or did).
How is step 1. Why is step 2.
Thanks for your input.
|
|
|
|
|
And that's why you have problems getting stuff to work.
When you have kids, expose them to loads of Tour de France, then put them on their first bike - no training wheels needed! - and let them cycle away down the hill.
Have an ambulance on call.
"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!
|
|
|
|
|