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.
Related
We need to read data from FoxPro 8 with C#. I'm gonna do some operations, and will push some of thoses data to an SQL Server database. We are not sure what's best method to read those data.
I saw OLE DB and ODBC; what's best?
REQUIRMENTS:
The export program will run each night, but my company runs 24h a
day.
The DBF could sometimes be huge.
We DON'T need to modify data.
Our system, wich use FoxPro, is quite unstable: I need to
find a way that ABSOLUTELY do not corrupt data, and, ideally, do not
lock DBF files while reading.
Speed is a minor requirement: it
must be quick, but requirement #4 is most important.
I would use the OLEDB connector - it has been updated much more recently, is faster and handles memory better.
If you are just reading data from the DBF via the OLEDB driver, I wouldn't worry about locking at record or file level, or corrupting data. All you need to do is handle exceptions in your C# code, for example when some process in your FoxPro application has the DBF open exclusively and you can't read it.
You also need to be careful that any queries are optimised to use available indexes on the DBF file, especially since you mention that it's large.
I assume this is all on the same LAN? If it has to work across the internet then you need to investigate exposing the FoxPro data via a web service.
Finally, there are other options for accessing DBF files.
Sybase also provide ODBC and OLEDB drivers that can access DBF files - however they cannot use FoxPro triggers, stored procedures and so on. That almost certainly doesn't matter in your case, though.
According to this MSDN article, it suggests using the Visual FoxPro OLE DB Provider. Look at the article and it gives examples on how to to use the OLE DB provider and how to query data from the DBF data source.
It's also quite easy to write some code in VFP that will dump the data to CSV or XML - consider adding this code to your FoxPro application. Processing these files could be much easier than trying to connect to a flaky FoxPro database.
There is a LinqToVfp tool on Codeplex. See: http://linqtovfp.codeplex.com
It has some nice samples that will help get you started.
I'm importing data from a remote MySQL server. I'm connecting to the MySQL database through a SSH connection and then pulling the data into MS SQL Server. There are a couple of type checks that need to be performed, especially the MySQL DateTime to the MS SQL DateTime. Initially I thought about using the MySqlDataReader to read the data into a List<T> to ensure correct types and then pushing the data into a DataSet and then into MS SQL Server.
Is this a good approach or should I be looking into doing this a different way? I can certainly do a bulk insert into SQL Server but then I'll have to deal with the data types later.
Thoughts?
I personally wouldn't use a dataset in the process, but moving it into a .NET type, then using a parameterized SQL statement will work just fine.
If you have a very large set, you might think of looking at a bulk insert, but that will depend on the size of the set.
Here's a Microsoft Guideline for going from MySQL to Sql Server 2000:
http://technet.microsoft.com/en-us/library/cc966396.aspx
SQL Server has a rich set of tools and utilities to ease the migration from MySQL. SQL Server 2000 Data Transformation Services (DTS) is a set of graphical tools and programmable objects for extraction, transformation, and consolidation of data from disparate sources into single or multiple destinations.
From reading this article you can import your MySQL without writing a line of C#
You know, if it's a process you need to perform but you aren't limited to writing your own code, you might want to look at Talend. It's an open source tool for ETL (essentially data transforms between data sources).
It's open source and has a nice GUI for designing the transform - where things come from and where they go to, plus what happens in the middle.
http://www.talend.com/index.php
Just a thought, but if you're just trying to reach a goal as opposed to write the tool, it may be quicker and more flexible in the long run for you.
The easiest way to do it to convert it to Timestamp.
Timestamp SetupStart_ts = rs.getTimestamp("SetupStart");
String SetupStart = SetupStart_ts.toString()
Push it to mssql server straightaway and it will save automatically in the datetime but varify it.Thank you.
We have a application that is making requests to a MSSQL DB via Entity Framework. One column in one table is a serialized C# class, stored in XML format. We would like to perform simple XPath queries against this data from C#. Currently we simply load the dataset, parse the XML via linq-to-XML then query the structure. This is of course the absolute worst way to solve this problem, so I'm looking for alternatives.
MS SQL 2008 can query XML data, so how do I do that through EF?
You can use a stored procedure. Or you can run dynamic SQL using ObjectQuery. Other than that, I don't know of any way to use the XML features of SQL Server through EF.
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
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.