tags:

views:

10

answers:

1

I'm writing an app which should take a sql file generated from mysqldump and import it into a mysql database. Is there a way to do this from ADO.NET or do I need to use the mysql cli?

A: 

You should be able to do this from ADO.NET by reading the file into a string and executing the string against the database, assuming that you have the ADO.NET connector for mysql.

I don't know what advantage you gain by doing that, and if you don't know the input well, you're asking for trouble, but it should be possible.

Andrew
I know the input well. It is a dump from a previous version of the database that I'm importing into a radically different newer version of the database. Executing the queries one at a time seemed risky to me since I would have to split on a char and would have to take care not to split if the char was part of the query instead of the terminator. So I just wound up piping it through the mysql Cli afterall.
Jason Thompson
You should have been able to use the entire file as one string and pipe it through the database, letting the db do the parsing. But, using the CLI was probably easier anyway.
Andrew