Main Menu
  • Welcome to The RPG Maker Resource Kit.

Visual Studio information handling help.

Started by TDS, October 08, 2011, 06:06:06 AM

0 Members and 1 Guest are viewing this topic.

TDS

I'm going to start by explaining my goals;

I am trying to make a database sort program for a list of cards that are imported into a text file and converted using a ruby script. Each card has many unique properties such as: Name, Level, Life etc.

My problem starts when it comes to saving and loading the information, and that is where I would like some help.

I have made different versions of the program, all of which use XML for saving and loading card information between tags. The version which saves each card into a different XML file works great, but the version that saves all card information into a single file tends to crash a lot because of files being already open and "XmlDocument" does not have a closing method to close a file after use. I know that is how it was made to work and that the problem lies my faulty code, but I cannot fix it.

So, I wanted to know if anyone here knew how I could make a database where I could store objects or information for each card and save and load to populate the fields in the program whenever I needed it.

I am using Visual Studio 2010 to make the program.

Thank you for reading and have a nice day.

Zeriab

#1
Try applying using clauses and see if that solves the problem.

using (xmlDocument)
{
    // Do stuff
}


I have made a snippet for helping saving xna games which you can study for reference: http://www.creationasylum.net/forum/index.php?showtopic=28156&st=0&p=333464&#entry333464
If this doesn't work let me know and I'll look into it more deeply.

If you really want to have a database then you can look into ADO.NET and LINQ, but from the usage you mention that will probalby to be overkill.

*hugs*

TDS

Thank you Zeriab.

I found a solution after trying to use "using" method, but sadly it required a close method for the object which xmldocument does not have.

I fixed it by using Try to catch the exception and try to save when the file was not opened.

ForeverZero

"Using" statements only works on classes that interface IDisposable. XmlDocument does not, so that would not work.