|
Thank you. Whilst I am not sure I would use an Interface to achieve what I need to do, you have helped me solve my problem.
Using Process I can see the main window's title from the instantiated class, because it is in the myprocess. As long as I have what I need there I can do it. It would be nice to be able to create a property on the process that I could see as easy to see it would be great.
Dim pReturn As Process
pReturn = Process.GetCurrentProcess()
cKey = (Left(pReturn.MainWindowTitle, 3)
All that is needed is a Select Case and I can change to the appropriate connection string for the company using the programme.
Thanks again.
|
|
|
|
|
I would not rely on the Main Window Title; any application can pretend to be your target.
If you can find the proces, then you can find the executable that is being executed. At that point, you can load that assembly and query its assembly-attributes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I need to set this source code on my new project. You can see my project and give me the reviews about it.
|
|
|
|
|
What you are asking about is the Data Access Layer (DAL - use this for your Google Foo). There are many articles and examples about this available.
As Richard said pass in your connection string, remember you need to move from development DB to production DB at some time!
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Yes, that would have been a route. But it isn't one I needed for this application.
What I didn't say is this is entirely an in house set of applications. Used to run this business. We have acquired another business and they too will run the applications - but against a different database, on the same server.
Writing something to pass the database name in to the class would have required hours of writing to change all times this class is instantiated.
Because it is in house I have hither to simply changed the CN string in the class before compiling everything to switch from test to production databases. The system is running, and being developed and new things are added - that is constant.
|
|
|
|
|
Presuming the application is a desktop solution, hopefully using click once deployment.
Your DAL should be included in each application project either as a DLL or a referenced project (I usually referenced the project to make debugging easier). EVERY database interaction should go through the DAL using the connection string supplied by the config file. You should only need to change the CN once for each deployment type (production/UAT/development) and this can be automated using compile directives.
A D Rosser wrote: Writing something to pass the database name in to the class would have required hours of writing to change all times this class is instantiated. This makes me think each table class interacts directly with the database, a thoroughly nasty situation. Changing to use a DAL does not have to be a singular task, all new operations should use the DAL and put a junior on changing the existing classes.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Good day programmers. I have an existing application that is already working online (.Nwt Core). Now on another application (.Net Core), I want to export all the images in passport folder in the first application to an excel file the import it to my new project
|
|
|
|
|
Hello po.
Ito po yung current code ko. Please help po.
TIA
Dim dt As New DataTable()
dt.Columns.Add("Name")
dt.Columns.Add("Count")
Dim manpower1 As Integer
Dim present1 As Integer
For Each row As DataGridViewRow In manpower.Rows
dt.Rows.Add(row.Cells(1).Value)
Next
For Each row1 As DataGridViewRow In present.Rows
present1 = (row1.Cells(1).Value)
dt.Rows.Add(manpower1 - present1)
Next
For Each row2 As DataGridViewRow In manpower.Rows
dt.Rows.Add(manpower1 - present1)
Next
absent.DataSource = dt
|
|
|
|
|
You are adding 3 sets of rows to your datatable instead of just 1. Try something like:
For Int row = manpower.RowCount
manpower1 = manpower.Rows(row).Columns(1).Value
present1 = present.Rows(row).Columns(1).Value
dt.Rows.Add(manpower1 - present1)
Next
absent.DataSource = dt
|
|
|
|
|
I have method which was working fine with PDFs has started giving errors, I checked in TFS - I didn't find any changes in that part of the method, I am getting the error: System.IO.InvalidDataException: 'End of Central Directory record could not be found.', but the PDF is valid and other clients told me it has started throwing errors for the pdfs previously were working. Here is the code:
try
{
using (MemoryStream ms = new MemoryStream(fileData))
{
List<string> dangerous_files = new List<string>();
string msgModel = "ZIP: {zip} - ({file})";
using (ZipArchive archive = new ZipArchive(ms))
{
foreach (var entity in archive.Entries)
{
if (denyExtensions.Contains(entity.FullName.Split('.').LastOrDefault().ToLower()))
{
dangerous_files.Add(msgModel.Replace("{zip}", GetRidOfSlash(file.FileName)).Replace("{file}", entity.FullName));
}
}
if (dangerous_files.Count > 0)
{
Response.TrySkipIisCustomErrors = true; Response.StatusCode = 500;
return Json(new
{
error = errMsg,
code = "500.1",
files = dangerous_files
});
}
}
}
}
catch (Exception ex)
{
LogHandler.LogError(4203, "Zip file creation failed Upload - Picture", ex);
throw ex;
}
The place where I am getting the errors is at the following line:
using (ZipArchive archive = new ZipArchive(ms))
Any help would be very very helpful - thanks in advance.
|
|
|
|
|
|
simpledeveloper wrote: I have method which was working fine with PDFs Are you sure? As far as I know PDF files are not in zip archive format.
|
|
|
|
|
which one is use tuple or out varaible . which is best?
|
|
|
|
|
|
If one were "best", there's no reason to keep it around in the framework. You can also use tuples as out variables, which makes your question unclear to me. Can you give us two examples of what you are trying to compare?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I have a SharpGL.openGLControl control installed on a MDI ChildWindow in WinForms. Although the ChildWindow's border is sizable, it cannot be resized using the mouse as the mouse does not "catch" on the ChildWindow's border to extend them. If the SharpGL control is removed, then the ChildWindow's borders become sizable again.
Would anyone have a suggestion how to circumvent this ?
Thanks in advance for any suggestion.
|
|
|
|
|
Hi, I'm making a WinForms app with Entity Framework. I need the computers to connect to a same database so all have the same data. I think this could be achieved with connecting them via Ethernet cables and writing the server, database, user and password, so the connection string updates to the given server.
I don't know how could I achieve this. Could you please help me?
|
|
|
|
|
The server does not broadcast its connection-string; it would make breaking into it too easy.
User and password are not required if your security up to date. If on the same network, all users can share data stored there.
As for help, the answer is "no". There's enough tutorials on accessing databases out there, and if they too complex I don't wanna help anyway. If you get stuck and have a specific question, we'll gladly help.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Using VS VB .NET.
The RichTextBox control does not have a way to disable keyboard/mouse input at least not in any practical way. Is there an RTB viewer control out there or enhanced RTB that can support this?
I have just discovered some of the enhanced RTB controls on this site which I will need to check out.
thx
|
|
|
|
|
Member 14694895 wrote: The RichTextBox control does not have a way to disable keyboard/mouse input at least not in any practical way. So the "enabled" property does not work for you or what?
Member 14694895 wrote: Is there an RTB viewer control out there You can make your own by simply displaying the results of a RTB without allowing editing. Have you considered converting the RTB to HTML and simply displaying it in a WebBrowser?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
UWP has a "rich text BLOCK" (besides a rich text BOX). UWP controls can now be hosted in at least WPF.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
It turns out setting ReadOnly to True does the trick. I want to be able to view it and use the scroll bars so setting to Enabled False is no good. That grays out the box and disabled the scrollbars. I want to stay away from HTML for now. Thanks for reply's.
|
|
|
|
|
Hi,
I have 3 tables in the back end - I am trying to load them using include statement of Entity Framework TableA is parent of TableB which is parent of TableC
(from a in TableA select a).Include("TableB").Include("TableB.TableC")
Now I want to get List<tablec> using a Linq, how can I do it? I am trying in the below way - its giving me compile error - any help please? Thanks in advance.
List<TableC> cs = (from a in tablea.TableBs select a.TableCs.ToList());
Any help in achieving this, that how can I get the List of TableCs in one list using linq queries
|
|
|
|
|
If you want a list of TableC s, then start with the TableC s. Use the navigation properties to include the parent and grandparent entities if required.
List<TableC> cs = tablea.TablesCs.Include(c => c.TableB.TableA).ToList();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes I did that - thank you for your suggestion
|
|
|
|