Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm currently working on a windows form application in C# and was wondering how to preserve data between executions? My application starts with a blank form that has a button that dynamically creates user controls, each one just containing a text box (picture a to-do list). The user has the ability to write into these text boxes, as well as dynamically delete them as well.
I've got the application all built and I can create number of objects, but I was wondering how I could save the data between closing and re-opening it. This is in VS 2015.
Much appreciated!
Essentially, you've got two options.
Store to file.
Store to DB.
Depending on your circumstances, privileges etc. you might want to call a web service and feed the state information to it. Then, upon re-launch, you just get read back from it.
Or, if that's a good option, you can simply store a local file with the information and then read from it. The exchangeability of data will suffer and you may face issues with access rights, though.
If the amount information that you need to store is fairly limited, you might simply write a few keys to the registry. The info will still be local and access needs to be granted but except for that, you'd be compartmentilize the data rather well.
In this case I would suggest making a list of your textboxes and then serializing their values and then saving into some format, let's say xml. It is possible to serialize whole list and then load it with simple code.
Edit: Maarten had a good point, I forgot about that you cannot serialize the whole component. I am assuming you are adding textboxes dynamically, so you already have some list/array of values.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last month.
Improve this question
My program is a desktop program made by .net7.
The program is running offline and the end-user is a factory, not all the factories have a network or are willing to pay for a network. We can't change this.
The program is used to verify whether the card has been used. The program reads the id (the id is something like Media Access Control Address that is unique) of the card, searches from the database and returns a result.
The data should not be stored in the card self for most people can clone a new card easily (but they can't clone the id).
As we know, we can store the data by database of file by encryption. However, someone can clear all the records by replacing a blank new database/setting or delete it directly.
The only idea for me is to save the data inside the program but not outside it.
Whereas, how can I achieve this? Or is there a better solution? Thank you.
In NTFS (Windows), you can use the alternate stream of the file. Although, technically, the user will still be able to delete it.
See this answer for details on how to do that with .
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have an application that gets all its data from an old AS400 application.
I get a model out (what in MVC I'd call a ViewModel) that has all the data for the reports, but the current legacy code is using the windows forms drawing API to place each box and label and data value on the report. It is hard-coded and maintenance is what you'd expect in terms of nightmare level.
I want to switch over to a report based on the data object or a collection thereof. I know how to write code against an object data source in ASP.Net, but I was wondering if the same can be done using SSRS for the report design, then using the objects collection as the data source. Has anyone done this?
Joey Morgan
SSRS is very extensible and you can write your own custom data processing extension that processes whatever data you have (in your case, the objects collection) and turns it into a dataset.
I've done this and while it isn't trivial, it isn't as hard as you might think and implementing a custom data processing extension may be a good way to solve your problem. There are plenty of examples online to get you started. I based mine on the file share example provided with SSRS that queries a network folder and returns the file information as a dataset.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am building a C# wpf SQL server application and before I start there are few things that i want to ask.
First of, the application will be used by several clients to write data into one SQL table. In the main window of the application I will have a datagridview that will display the main table. Since data is going to be entered by more than one person, can I dynamically update the datagrid view or should I use a timer and update in once every few minutes?
Is it better if I open one global SQL connection and keep it open while the application is running (and if it is how can I do that) or should I create a new connection each time I want to do something?
These are the questions for now, I am sure I will have much more questions in the progress, since I am new to wpf and database programming. Thanks for the understanding :).
I recommend you to build your wpf application in mvvm architecture.
As for me, I think you should not use timers for this purpose. Because if your client will use different filters or sortings, to find custom data rows, these sudden data updates will change displayed data order, which is an unpredictable behavior (breaks UI development principles) and it will annoy everyone. The better solution, is when users will refresh data only when they need it (manually, button click), or on navigating to dataGrid table control himself (automatically).
If a client takes a record on editing, you can store record State parameter in database, and check its state to avoid collisions (editing of the same data in the same time by multiple users).
You should not keep the connection alive explicitly, when you're not make operation with dataBase. Since you're using WPF - the best, easy to configure and managing approach - to install EntityFramework nuget package to your project, and use Code first.
Here is a good tutorials, about how to use it.
Working with your database through project models is much more reliable and simple in realization, than working through SqlConnection classes.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I want to be able to control directly in my program, what other users can do or can not do. I have an ActiveDirectory where the users are saved in 4 different right groups: "User" (Basic function to start the program), "Sales", "Accounting" and "Management" (Administration). The program checks which rights the user has. So right now I have to change the Code and release a new version if I want to change the rights for example "Accounting". But in near future I want to be able to just go to a special window in my program for something like "RightsManagement" and change which group can use which feature. These "RightSettings" should be saved in a global file which will be loaded from every user in our company. That's for the theory...I would like to know if there is a perfect way to do this, I would like to get many different approaches to this problem so I can choose the best for me. Something like a read-only Xml file?
It could be a xml file which is placed in a network drive so the program can access the file from every pc in the company. And that file should be read-only for users so they cant change the settings in that file. Of course through code and the "special window" Admins can set these settings and therefore overwrite the file.
Thank you for your help!
There is no perfect way. You could use a file on a share; a database; AD itself, a web service etc etc. Each has advantages and disadvantages.
You need to ask yourself a set of questions:
Do you have a database server you could use for this, or can you set one up easily and cheaply? How knowledgeable with regard to SQL are you?
What kind of access do you have to AD and how comfortable are you with writing an admin app to manipulate it?
Do you have a suitable file share that everyone, save admins only has read access to and for which admins have write access?
and so forth, depending on which solutions you consider. Only you can ask the full set of questions and answer them and therefore come to a conclusion on which is best for you.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a small simple project on building a clickable interactive map of our school.
The challenge is to create a clickable parcel of map and add an animation
directing the user from point A to B using the given roads/hallways on the map. Moreover, I would like to create a database that allows the user to view the information for that specific parcel of map when clicked.
I'm using C# to program this one. My application is Visual Studio 2010
Example Links:
https://www.youtube.com/watch?v=tbinL2pg5Hs
http://www.wayfinderkiosk.com/
QUESTIONS:
What are the processes(step-by-step) on creating this project?
What applications should I need for programming, database, animating, drawing etc.?
Decide on the platform you will be using: WinForms, WPF, WinRT, ASP... If your project description includes the platform then you know; if not keep the question in mind!
Get your resources. Get the map and a list of all the places you will work with. Also all the extras like the descriptions and photos etc. Get this chore out of the way now. It'll help you to get a feeling for the amount of things you will put into the project.
Know your clients. An older kiosk system runs only only a few kiosks. Today maybe you need/want to have it run on the web and on portable devices. This will make a difference in not just for screen sizes but also in the number of possible routes..
Define user input controls. Keyboard? Mouse? Touch? Which buttons? You need a complete list!
Define the user interactions. Completely. Try to make tables of states the system can go through.
Try to decide on how the path finding should work. This anything but trivial, as soon as you want to include more than a few points.. You can have a set of ready made paths or try to find them or build them from a list of partial paths. This may well be the toughest part of it. Some folks believe in 'Hardest First' other in 'Hardest Last'. I believe that the first thing is to understand the hard parts well enough to get a feeling for them and to decide then.
Well that is really just a start, off the top of my head.
Good luck and have fun!!