Best way to store data in wpf app - wpf

I just want to know about the best way to store simple data in wfp application. I'm using SQL CE, but sometimes I need to store simple data (for instance one string). I don't want to use for it db, and I think it's the right decision.
Could you please give me a guidance on how should I do that in best way or any useful resource?
Is there any particular features data settings storage for pattern MVVM?
Thank You.

Use Settings for exactly this scenario. It's simple, allows per user and system wide scenarios and is build into Visual Studio nicely.
Double clicking on Settings.settings in the Properties folder of your project (in Solution Explorer) brings up the editor and you can access these in code with something simple like Properties.Settings.Default.StringPropertyX.
http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx

if you're going to be upgrading in the future, I suggest that you create a small abstraction layer that you can upgrade to using any DB or other source, when you need to.
Until you do the upgrade, I would suggest a simple XML file using XDocument and XElement (and the rest of that api).
The reason why I am suggesting this is because you can use Linq on them easily and this enables you to change the provider in the future without any problems.
here is the MSDN on XDocument http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.aspx .
I hope this proves to be helpful to you ;-)
Cheers,
Max
p.s. lemme know if this is what you needed or not!

If you publish the application through ClickOnce then you can use IsolatedStorage. It is pretty easy to use, just a few lines of code. You can learn how to use it on WPF isolated storage.
If you don't publish it through ClickOnce then I would suggest you keep it simple and use static class.

you can use file system.. try to create xml file or csv file in the wpf app directory...
you can read and write to same file.. so that you can save what ever you want to that file and read from the same file..

Related

How to store data with version controll and make it easy to edit and use in applications

I want to store a set of data (like drop tables for a game) that can be edited and "forked" (like a open source project, just data, so if I stop updating it, someone can continue with it) like a coding project. I also want that data to be easy to implement in code (for example, the same way you can use a database in code to get your values) for people that makes companion apps for said game.
What type of data storage would be the best for this scenario?
EDIT: By type of data storage I mean something Like XML or JSON or a database like Access or SQL as well as noSQL
It is a very general question, but I'm getting the feeling that you're looking for something like GitHub. If you don't know what that is, then you should probably look into it. GitHub supports svn and allows you to edit your code quite easily and let you look back to previous versions of your code. Hope this helps!

Work with Database using Spock and Geb.

I hope someone have already faced an issue to verify that application shows correct data from database. I reviewd how groovy used SQL, but I have no idea where and how I should do that. I'm just starting to use gradle+Spock+Geb for testing application. I have a few files where I described a couple of pages from application, a couple of modules and a file with spock specification. Where and how I need to connect to Oracle DB, use SQL and compare result's data with application's ones?
P.S. I write everything in notepad++ and launch from command line writing 'gradlew firefoxTest'. Does exist any more comfortable way to work with gradle+spock+geb?
Thanks in advance.
Because there are no other answers, I wanted to provide a solution someone at my company thought of. This assumes you already have a project that uses some sort of JDBC. In our case it is JDBI.
The idea is to extend Classloader and then use that to directly access the data access object class via the JVM. That idea should work.
I have not tested it out because it doesn't completely fit our use-case. I'll admit that this does not completely apply to your use case, but technically you could just run the jar of an existing project, which can access the database.

How do I put and replace a file using in a client machine in a Silverlight app?

I'm trying to make a Silverlight app which has a local sqlite file to search some data when the app gets offline. I found the following library, http://code.google.com/p/csharp-sqlite/ and it seems pretty nice.
So, what I want to know is, what is a good approach to have and place a file which might be replaced by automatically when the data in a server gets updated at some points?
I've tried to put a file into a folder under the app, but I couldn't access to the file by using csSQLite.sqlite3_open (This method is from the library above). Sorry, I'm pretty new to Silverlight, so my question might be very odd.
Thanks in advance,
yokyo
It doesn't look like this library has been specifially coded for Silverlight. Despite being a pure C# implementation its still likely to assume the full .NET API is available. This is not true in Silverlight.
Specifically Silverlight cannot ordinarily access the local file system. The SQLLite code would need to be modified to understand Silverlight's IsolatedStorage. It would also have to limit its file operations to those that are supported by the streams available Isolated Storage.
The creation of a DB-esq. data source in Silverlight is typically done by create Classes the represent records and collections of records, using LINQ to query them and Xml serialisation into Isolated storage to persist them.
Here is a hacked version of the SQLite code to work with Silverlight, you can use it for some ideas on what to do: http://www.itwriting.com/blog/1695-proof-of-concept-c-sqlite-running-in-silverlight.html

Silverlight3: What to use: WebClient or database with RIA

I'm asking for the advice. I'm working at the Silverlight 3 application and now I should select the mean how to save the information and get it. I could save the necessary info in files (from 1 to 300K size) or I could save them in database. If I would use WebClient for accessing to separate file there's very low loading of the server. If I get data from database the server would load much more I think and the code on the server too.
Please correct me if I'm not right.
I'm looking forward to hearing from you!
Thanks
there are additional considerations if you use a file that is localized to the users machine. If you wish to save data w/o any user intervention then you are limited to using Isolated Storage, which has constraints on the size of your data. Otherwise, you have to ask the user for information on where to save/load the file. This is due to the security model used by silverlight.
i am thinking that a Database and the RIA framework might be the way to go.
just my 2ยข
If you are saving and loading the entire file at a time, then it might be okay to use a WebClient. This might take a little coding to handle errors that may result in incomplete saves.
If you're serializing some objects or xml data and storing that in a file, then you should probably be using a database instead.
Edit: It can be a pain to get WebClient or HttpWebRequest working correctly with GET/POST, but WCF can also be a pain to configure if you haven't done it before. WCF is probably better style, and you'll want to use a binary binding and send the file across as a byte[].

Best way of sending a file to SQL server and save it, then reading it from DB?

I am developing a software with vb6.0 :( .
I wanna to know that what the best code for saving a file in SQL server and then reading from it is?
I should say that I use ADODB.Stream when saving file.....
what is you suggestion?
Do you need to save to sql. An alternative, and IMO better solution is to save the docs to a folder on your regular file system and save the reference to it in sql.
Unless you have specific reason for wanting to save in sql?
Is there a specific reason you need to use vb6. Legacy?
Here is an example in .NET on achieving what you require, it should be pretty straightforward to convert to VB6
http://www.jstawski.com/archive/2007/05/17/save-documents-with-sql-server-and-display-them.aspx
UPDATE: With VB6 an example using ADODB.Stream to store and retrieve images, which should be similar to what you need:
http://www.devx.com/tips/Tip/14246

Resources