Need some advice

M

Mark Moeykens

I'm building a WPF app for single users. They enter data, saves to xml file.
They can share this xml document with others who have the same app.

I wanted to keep it simple so basically when they open the xml file I do a:
DataSet.ReadXml("filePathToXml");
When they save their work I do a:
DataSet.WriteXml("filePathToSaveLocation");

Now that I'm further into development I'd like an easier way to query that
data in the dataset with some kind of complex joins.

I know from my full-time job we use DataSets connected to SQL and just add
TableAdapters hooked to stored procedures or sometimes just write the query
right in the TableAdapter methods.

This sounds good but I find that 2008 doesn't offer this ability for Xml
files as far as I can see. Maybe because I just have the Standard version of
Visual Studio.

So does anyone know how I can take advantage of the TableAdapter querying
capabilities with an Xml file as the datasource? Can it be done? If not,
should I pursue a different direction?

Thanks!
Mark Moeykens
 
M

Mark Moeykens

Yeah, I've looked into many options and I think it's all going to come down
to having to manually writing code and queries and more unit tests. Anyone
know of any VS addins that can make querying xml easier like DataSet
TableAdapters do for SQL Servers?

I've also thought about the possibility of loading the xml into a DataSet
that's connected to an .sdf (SQL Compact Edition Database). Then I could
create the Tables and TableAdapters and have autogenerated methods to return
data from the TableAdapters. The sdf would be nothing more than a temporary
holder of the data with the DataSet facilitating with the selects, inserts,
updates and deleting of data. Then when the user saves I do a
DataSet.WriteXml.

I'll have to look into packaging and deployment and the SQL Compact Edition.

Mark Moeykens
 
M

Mark Moeykens

Thanks guys. I have already incorporated SQL CE into my app and it works
great with the DataSet and TableAdapters.

I'll still be sticking with the XML DataSet output so they can save their
information to a file. It's important that they can use the app, enter a lot
of information and then save it off and send it to another person.

Use the DataSet.WriteXml() is so easy that it's the best method I can think
of at this point in development.
 
M

Mark Moeykens

Oh wow! I didn't know that! That sounds really exciting. It seems I need to
study up on this and figure it out more.

So basically it sounds like when the user opens a .sdf file through an open
dialog box I just set that path as the .sdf's connection string. And when
they want to create a new .sdf...well, I imagine you just instantiate this
object and then write code to create all the tables necessary in memory until
the user wants to save it and then I just create/persist the object as a .sdf
file. I'll have to research that part to see how to dynamically create and
persist these files.

Thanks for the heads up though, that definitely sounds like a better deal
than the xml files.
 
M

Mark Moeykens

Wow guys, this is beautiful! Here's how you create a new SqlServer Compact
Edition file:

[Test]
public void CreateSdfFile()
{
string connectionString = @"Data Source='c:\Test.sdf';";
SqlCeEngine sqlCeEngine = new SqlCeEngine(connectionString);
sqlCeEngine.CreateDatabase();
}

Steve Lasker also has a pretty good post on instantiating and initializing
the database file with table definitions:
http://blogs.msdn.com/stevelasker/a...pact-edition-database-and-schema-in-code.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top