|
|
Thanks Gerry.
I had already read that article, but I'm still not understanding how to get the (maybe) changed settings out of the Property Grid and back into the actual Settings object before saving the settings to the proper settings file.
I'm thinking I need to iterate each setting in the Property Grid, compare it in code to the Settings object, and for each one that doesn't agree, update that setting in code, THEN execute the save command.
Remember, I instantiated the Settings object, and used that to bind to the Property Grid. Still not sure I did that part correctly either, but it does cause the settings to appear in the Property Grid.
|
|
|
|
|
Never used it but the docs say the Property Grid is for "browsing" ... How are you actually changing the settings?
I have my own custom "settings" code (serialize; deserialize). I verify the settings as a whole; I don't need to go back and see what "changed".
Any object can be iterated using reflection; so if you had to compare, I'd use reflection to compare like named members if it came down to it.
"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
|
|
|
|
|
Thanks Gerry.
Not sure what is meant by "browsing". If the property grid is bound to the Properties.Settings collection, they (the settings) just appear in the property grid at run-time. Depending on how the grid is bound, it either updates the settings immediately if you make a change, or you have to iterate the grid items to see if any changes were made. For each of the changes, you need to update the setting itself. This is decided when instantiating an object to the settings collection before binding the property grid to it. If you use the New keyword, settings are not auto-updated, you need to update each grid item value to settings. If not using New, the changed values are updated immediately. Either way, you need to remember to save the settings.
I chose the first method (New) so if a user "accidentally" changes a setting in the grid, they just click the Cancel button and nothing is changed. Otherwise, they need to click the Save button.
|
|
|
|
|
I got this working now. It loads the settings into the PropertyGrid perfectly. Since I'm not limiting it to User settings, it shows them all, both User & Application. Since Application settings are read-only, the PropertyGrid helpfully makes those grey'd out.
Interesting quirk: If I bind the PropertyGrid to an object instantiated from the settings themselves, changing a setting in the PropertyGrid directly updates the User settings. Just need to remember to save the settings before closing the form.
Since I wanted this to not auto-change the settings, I created a Save button, and bound the form to a settings-type object using the New keyword. If I change a setting in the PropertyGrid, I iterate its items and compare each value to the current matching setting value. If different, I update the settings right then, and set a bool flag that something has changed. After completing iteration I save the settings and we're done. Works great.
Now I want to be able to add a new setting.
Does anybody know what the enumeration name is that contains the different setting types? You can see them in the project properties, Settings tab, when you go to add a setting. The Type drop-down shows many types (string, char, bool, int,...). I'd love to be able to choose which type in code when trying to add a new setting.
Thanks...
|
|
|
|
|
This one's on how to create new application settings.
How to: Create Application Settings - Windows Forms .NET Framework | Microsoft Learn
"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
|
|
|
|
|
With the help of a Udemy course I am learning ASP.NET Core MVC. The course is this one:
https://www.udemy.com/course/aspnet-core-mvc-configuracion-e-implementacion-net-6/
I haven't finished it yet, but I already have a question: Is it possible to host the application on a Linux based webspace, where .NET Core is not installed and to make it worse, I don't have root permission to install it? On this webspace I can host Wordpress, Joomla, HTML+CSS etc. Is it possible to publish the ASP.NET Core MVC application in such a way, that everything that is needed is included?
Thanks in advance for your help.
René
|
|
|
|
|
temuco wrote: Linux based webspace, where .NET Core is not installed
The binaries require OS specific calls so you would need libraries that support the linux version. Been years since I looked but in the past those existed for .Net.
temuco wrote: Is it possible to publish the ASP.NET Core MVC
With minimal information provided but with you saying that you "host" wordpress then I would say yes. Figuring out all of the libraries is going to take a bit but should be possible.
|
|
|
|
|
temuco wrote: With the help of a Udemy course I am learning ASP.NET Core MVC. Does the course offer any support ?
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Thank you, I will ask. You're right, I hadn't thought about that.
|
|
|
|
|
Hello dear experts,
I have been having sleepless nights trying to figure why my insert statements keep inserting duplicate records and at this point, I am so stumped that I could really, really use your superior skills to help me out.
First some background. I have been with this company for a little over two years and I was handed over an application that keeps breaking, mostly due to poor DB design.
I am asked to not discard the current DB design to "work with what I have."
The application accepts applications for request for some financial assistance but the applicant must meet certain conditions in order to be considered. If the applicant does not meet conditions, the application is rejected and returned to the applicant with reasons why it is rejected. The applicant is asked for adddress (install address and mailing address are requested.) there two key items to look for.
(1), Is Install address (residential address, same as mailing address?
(2), Is the application returned (rejected) or not.
So, here is what the code I am working with is supposed to do.
It searches the db for records and if record exists, then the code checks whether the application is rejected or not and is does install address same as mailing address or not.
The logic goes like this:
If applicant's address is same as mailing address (if SameAsMailing.Checked)
If record exists, then if SameAsMailing.Checked and returnyesorno.SelectedValue=0 Then install address is same as mailing address and it is not a return then update three tables (Addresses, Owner and Application tables).
If SameAsChecking is not checked and returnyesorno.SelectedValue=1 then install address is not same as mailing address, therefore, insert the both the install address and mailing address and also process for return by inserting records into Addresses, Owner, Application and return tables.
If install address is same as mailing address but not for return, then insert into Addresses, Owner and Application tables.
Finally, if install address is not the same as and also not a return then insert into Addresses, Owner and Application tables.
No matter the variation that I use, I keep getting about 4 duplicate records inserted into Addresses and Applications table.
It is a complicated mess and I need whatever help I can get from you superior talents, please.
Here is what makes it so complicated.
On the Addresses table, there are three key fields, AutoID (integer) Mailing and Installation are BIT datatypes.
If both Install address and mailing addresses are same, then both Mailing and Installation get value of 1 (true) and therefore AutoIID gets assigned same value.
If install address nd mailing address are different, Installation gets 1 and Mailing gets 0
Then on Applications table, there are two key fields, MailAddress and InstallAddress (both integer datatypes)
If Mailing and Installation (from Addresses table) both have a value of 1, then both MailAddress and InstallationAddress get the value of AutoID, say 123
If the Install Address is different from Mailing address, AutoID should get 123 for InstallAddress and 1234 for MailAddress.
I have tried various combinations of the insert statements but to no avail.
I have attached a copy of my code and it is very long.
I ask for your patience and assistance. Please help. I have delayed giving management demo and they have insisted that I show something by wednesday March 15th. Any assistance you could give would really, really be very helpful.
Thank you in advance for your patience and assistance.<a href="https://www.kenig-dev.tech/wp-content/uploads/2023/03/code.txt"></a>
Richard Deeming, could please help me? Sorry to call your name. I will just this time only because of my desparation.
|
|
|
|
|
Out of interest, I took a look at your code. Honestly, that's going to be almost impossible for someone else to solve in its current form. Some of the things you should look at, to make it more readable.
- Actually use SQL Parameters properly. Right now, you're creating sql parameters, but you are injecting the values directly into your SQL statements - this means you are open for SQL Injection attacks
- Break the logic up into smaller chunks - that code is far too long to understand
- Close your connections when you're finished with them. You are going to hit issues very quickly if you don't.
- You're issuing insert statements that are using a value of -1 inserted records to determine whether or not a record is a duplicate. Rather than doing this, you should actually use real duplicate checks. You should use something like
IF NOT EXISTS (SELECT ....) INSERT INTO .... , but be aware that it is technically possible to still get duplicates if you encounter race conditions.
modified 13-Mar-23 7:27am.
|
|
|
|
|
Thank you very much for the pointers Pete, much appreciated.
For the first point you raised about sql injection attack, yes I forgot to explain that I did those intentionally so I could see what values are being passed to them when I try debugging the old fashioned way - using response.write().
I intent to use the sql parameters once I am able to work out all my issues with the code.
There are three questions at play here and I believe this is where I am having my issues.
1), Does this application already exist on our DB? If yes, is it to be returned (rejected).
2), Is this application we received to be returned and is the install address same as mailing address?
3), Is this application to be returned and is install address and mailing address different from each other.
If the answer to #1 is yes and no, then the user just updates the records
If the answer to #1 is yes and yes, then the user updates the records and also process it for return by inserting it into Returns table.
If the answer to #1 is no (record does not exist for this application). So, it is a new application but needs to be returned, then it is added to the all the tables I mentioned above as well as return table.
If the application is new and not a return, just add them to the three tables mentioned above.
We also have to process the application based on whether residential address is same as mailing address.
Unfortunately, if I was designing the DB, I won't be having this issue now because I would have two tables, one for residential address and the other for mailing address but unfortunately, here we are.
Very depressing to have to deal with this.
modified 13-Mar-23 11:08am.
|
|
|
|
|
If the database design is wrong, you don't "live with it"; you change it. Most "DBA's" have no practical application experience and design "from a book"; where performance and ease of use takes a back seat to 4th normal form.
"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 completely agree with you Gerry.
The reality is we did make some changes to the DB but is sticky about this is that users are insistent on having the ability to search for and retrieve existing data and the change I need to make will make that nearly imposssible.
So, yea, I have to live with this.
|
|
|
|
|
Change can be introduced in different ways. You can extend; once the extension works; you cut away the part(s) the extension replaces. If you need to "stop" the system to make a change, it's the wrong kind of change. They didn't remove the Frank Slide; they built a new road around it.
"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
|
|
|
|
|
Ihechi Alozie wrote: I have delayed giving management demo and they have insisted that I show something by wednesday March 15th. Show them this message.
Ihechi Alozie wrote: I am asked to not discard the current DB design to "work with what I have." And how, does management know that such is better than adapting the damn thing? What programming knowledge do they bring to the table to say whether or not that is a good idea or even viable?
Would you hire a damned plumber and tell him not to use pipes? Do you tell the surgeon how to do his job? You hired a programmer for his knowledge. If yours is superior, you don't need him.
The damned db IS the problem! If you keep that, you insist on keeping the core problem. Tell the programmer to normalize the DB design first. Then migrate the DB overnight and move on.
If your toilet-selling company is listed on the stock exchange, then I will be betting on you loosing money. If I need to judge you as a company, just imagine the sound of a toilet flushing.
Let the dev do the dev thing, and you keep managing the stuff that needs managing. I'm not joking; you handicapped a dev, and set him up for failure. Now, he needs to "show a demo" of something that doesn't work because you arbitrarily decided so.
Normalize the DB. Adapt your app to work with it. Then migrate all data. Work from there or accept that the company will be "bits".
I would help your dev to do so; on the one condition that you stop interfering with his work. Trust in the employee.
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.
|
|
|
|
|
You guys are on point.
Thank you guys for your useful inputs.
I will keep tearing away at this, slowly but surely.
|
|
|
|
|
Slow but sure wins any race.
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 have been looking at the code that gets generated when you add new scaffold items for Identity into an web application. I notice that often a UserManager<TUser> gets injected along with a SignInManager<TUser>. It seems that the SignInManager has a property for UserManager. Is there a reason to have them injected separately instead of just injecting and using the SignInManager? Can there be situations where the UserManager property is null in the SignInManager but would have been injected into the constructor?
var userId = await _userManager.GetUserIdAsync(user);
var userId = await _signInManager.UserManager.GetUserIdAsync(user);
|
|
|
|
|
It comes down to separation of concerns.
SignInManager is used by the UI to get credentials, authenticate, and maintain login state, while UserManager is concerned with managing the database of users and authenticating credentials passed to it by a SignInManager.
Yes, the SignInManager has a UserManager property, but you have to pass a configured UserManager to the SignInManager when creating an instance of that.
|
|
|
|
|
Yes, ASP.NET Identity requires distinct SignInManager<TUser> and UserManager<TUser> classes.
The management of user accounts, including their creation, updating, and deletion, password resets, and email address confirmations, is under the purview of the UserManager<TUser> class
SignInManager<TUser> class is responsible for handling the authentication and sign-in process for the application
|
|
|
|
|
This is my first time that i post here and i hope that topic is correct is placed.
Please who can help me?
Error message is:
An unhandled exception of type 'System.InvalidCastException' occurred in System.Data.dll
Additional information:
This rows give error (the code was writed for MySQL and i have self changed to MS Access):
Dim len As Long = rd.GetBytes(0, 0, Nothing, 0, 0)
Dim array(CInt(len)) As Byte
rd.GetBytes(0, 0, array, 0, CInt(len))
pic = New PictureBox
Dim ms As New System.IO.MemoryStream(array)
Dim bitmap As New System.Drawing.Bitmap(ms)
pic.BackgroundImage = bitmap
Full Code:
Imports System.Data.OleDb
Public Class Form1
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim rd As OleDbDataReader
Private WithEvents pic As New PictureBox
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Dim con As OleDbConnection
'Dim cmd As OleDbCommand
'Dim rd As OleDbDataReader
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\database.accdb;")
con.Open()
cmd = New OleDbCommand("select * from MyTable", con)
rd = cmd.ExecuteReader
MsgBox("connected")
con.Close()
MsgBox("disconnected")
End Sub
Sub LoadData()
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\database.accdb;")
con.Open()
cmd = New OleDbCommand("select * from MyTable", con)
rd = cmd.ExecuteReader
While rd.Read
Dim len As Long = rd.GetBytes(0, 0, Nothing, 0, 0)
Dim array(CInt(len)) As Byte
rd.GetBytes(0, 0, array, 0, CInt(len))
pic = New PictureBox
Dim ms As New System.IO.MemoryStream(array)
Dim bitmap As New System.Drawing.Bitmap(ms)
pic.BackgroundImage = bitmap
FlowLayoutPanel1.Controls.Add(pic)
End While
rd.Close()
con.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
LoadData()
End Sub
End Class
|
|
|
|
|
sdfsdfsdfewrew3feff wrote: This is my first time that i post here
And yet you've apparently been a member for 12½ years, and posted 22 messages. Did you mean this is your first post in the ".NET Core" forum? Or have you managed to grab someone else's account by mistake?
sdfsdfsdfewrew3feff wrote: select * from MyTable
If you're only reading one column, then only select that one column. If you use select * from ... then you're subject to the whims of the database engine as to which order the columns are returned in.
You're presumably getting the InvalidCastException on the rd.GetBytes line, which suggests the first column being returned by your query is not your image column.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry, Richard. I was forget and it long time ago.
When i select a column than i get new error "From".
Additional information: The FROM clause contains a syntax error.
|
|
|
|
|