Convert a c# mdb solution to xml? - c#

I have a system that uses an mdb database with an xsd descriptor written in c#. Now I want to use one or more xml files with the same data instead. I have generated a couple of adapters for the mdb, but now I don't know what is needed for using xml instead. Anyone have some tips? I have managed to save the mdb as a few xml files.

Very unclear, XML is a very poor substitute for a database. I reckon you'll want to use DataTable or DataSet to load the .mdb data. Their WriteXml() method makes it very easy to generate the xml.

The XML is not fully substitute for relation database. The dataadapters are not supposed to work with XML files and the SQL language too. I recommend you choose another SQL database (you need propably some embeded database - such as Firebird, PostreSQL, SQLite, MSSQL CE, etc...). You can still use a OLE DB data providers (DataAdapters, DataReaders, etc...) and the data layer will need only little change because of SQL dialects.
However, if you need the data in XML, you need change whole data access layer.

Related

dump XML into MySQL

I've got a database dump in XML coming from some Windows application. I believe its SQL Server 2008 data dumped into XML via C#, although I do not have access to the source. I only have the dump.
The XML file matches this format:
MSDN DataTable::WriteXmlSchema
Is there a known / convenient way to import this into MySQL? Is there anything in VisualStudio or MySQL Workbench that might help?
MySQL (as of version 5.5) has a LOAD XML syntax, see this link: https://dev.mysql.com/doc/refman/5.5/en/load-xml.html
If your data doesn't fit that schema, you might be able to transform it into that schema.
Otherwise, you could use the ODBC .NET Managed Provider to talk to MySQL from C# (http://support.microsoft.com/kb/310988), although I don't know whether it has been tested, or whether it is supported for MySQL.
From there you could parse the XML and create insert statements, etc.
Or, if you can't get the ODBC provider working, you could write a program to parse the XML, and write the appropriate SQL statements to insert all the data.
In short, you get to have fun with this.

How can I store data on client computers without using data servers?

How can I store data on client computers without using data servers?
I have C# Windows app and want to store some data on the user's computer. I don't want to use any type of data server like SQL Server or Access. The user can not read this data and this data is structured like tables with row.
What is the best way to store my data? And how can I handle this case?
Notice that I want to edit and update this data.
All of my data types are string, and I don't want to only store in-memory because after a system reboot the data must still be available for my application to work.
Edited for clarity.
There are 2 questions:
Where to store the data? %APPDATA% is a good candidate for application specific data and %UserProfile% for user specific data.
What format and file type should you use? You can store it in many ways, including structured or unstructured formats such as XML, CSV, etc. If you don't want the user to be able to read the content, you can encrypt it in some way. You can also choose to use a local database type, such as SQLCE or SQLLite, which could provide the security you may be looking for.
I would suggest using SQL Server Compact which is a lightweight, file based version of a database.
Your users do not have to have SQL Server installed to use this option.
This would be my preferred option as it allows you to use LINQ to work with and query the data in the file very easily using technologies such as Entity Framework. In fact you can use POCO's to represent your application entities and Entity Framework will take care of reading and writing the information to the database.
If you are using Entity Framework you can automate the creation of the database using the configuration file. The first time you use any entities the database file will be generated automatically for you (this can be configured).
<configuration>
<connectionStrings>
<add name="DatabaseContext"
providerName="System.Data.SqlServerCe.4.0"
connectionString="Data Source=C:\Paths\To\Location\DBName.abc"/>
</connectionStrings>
</configuration>
I would suggest using one of the special folders on the system to make this transparent to the user of your application.
Also notice that you can have whatever extension you want (DBName.abc instead of DBName.sdf) so that the file can be associated with your application.
Using this method also has the advantage that you do not have to load your entire file into memory in one go (I.E. you can query the data and return a subset of the data) which you would not be able to do if you simply serialised your object to a file.
You can use SQL Server Compact, it's a DB in a file
or
If you prefer, yo
You can use XML, its a pretty standard aproach, if you dont want to use DB's.
PS: If you want many users to use the same XML also lock the file on each operation so you will avoid concurency read/write errors.
And a notable advantage is that you can use LinqToXML to perform queries :)
since it is an windows app, you can create a folder where the app is installed and create MS excel file and save your data in that excel file.

Can I import data from SQL Server into SPSS?

I am writing a C# form based application that stores its data in SQL Server 2005.
My client wants to use this data in SPSS.
My original plan had been to create a database view which matches the SPSS structure. This could then be exported as a CSV file and copied into SPSS.
However, I just heard there may be a way to import data from a relational database directly within SPSS? I haven't been able to work out how to do this (I can see an export to db option, but not an import)
Does anybody know if data import from SQL Server is possible in SPSS? Or if there is an easier way to achieve this than by using the approach I outlined above?
Many thanks!
--- L
Just to add to this, you can import from a number of ODBC-compliant data sources. IMO, SPSS does this much easier than SAS, if you were comparing those two tools only. It is true that you have to save an ODBC connection up front, but after that it is a breeze!
In addition, with newer versions of SPSS (I know it was in Versions 18+), you can WRITE data back to a database. This is an unbelievebe feature and they make it very easy to do. We recently started leveraging this feature at work and it gets around needing to store multiple versions of the save SPSS file on a shared network drive, helps with reporting (can feed predictions) to a data warehouse that helps with reporting (i.e. Cognos), etc etc.
For any future searchers... I solved this by using the "Open Database" option under File menu, then selecting "New Query..."
I had to add appropriate ODBC drivers, then was able to create new joins between tables, and rename variables as required.
Easy once I stopped looking for something called 'import'! DOH!

How to store XML files in SQL database using C#?

I have an XML file which should be a part of a table in my SQL database (say, name, data and XML).
I prefer not to make a string of it if possible.
What column type should I use for it? I chose XML but I'm not sure how to work with it.
A small code example would be very appreciated.
Thanks.
SQL Server (if you're using it) has an XML datatype which you can use. I've never used the datatype but we covered it during an SQL Server/.NET course at university.
http://msdn.microsoft.com/en-us/library/ms189887.aspx

How to store data in a table locally and present it in C#

I want to setup a table that can:
Save the data on the user's machine
Reference & present the data in the GUI
Capable of adding rows dynamically during runtime
What's the best way to go about this?
DataGridView or TableLayoutPanel or...? I'm having trouble with SQL server CE, as I was going to connect it with the DataGridView, but I'm very new to this kind of work, and wondered if it was even necessary to use SQL.
SQL CE should work OK, but no: you don't have to use SQL. You could just populate a DataSet and save/load that to a file on disk. Or you could use any other serializable object tree and a serializer such as XmlSerializer etc. All of these should work fine with standard bindings like DataGridView. Note, though, that databases get you more granular control over the data. It all depends on whether that is valuable, or if a single flat file will suffice.

Categories

Resources