开发者

How can I import an SQL dump file into a DataSet in C#?

开发者 https://www.devze.com 2023-03-16 11:22 出处:网络
I\'ve got a bunch of SQL dump files that I\'d like to import into a dataset with C#. The machine this code will run on does not have SQL installed. Is there any way to do this short of parsing the tex

I've got a bunch of SQL dump files that I'd like to import into a dataset with C#. The machine this code will run on does not have SQL installed. Is there any way to do this short of parsing the text manually?

Thanks!

EDIT: The Dump file is just a long list of SQL statements specifying the schema and values 开发者_如何学Pythonof the database.


Is this a SQL dump of the backup sort that you create via a DUMP or BACKUP statement? If so the answer is pretty much no. It's essentially a snapshot of the physical structure of the database. You need to restore/load the dump/backup to an operable database before you can do anything with it.


I am pretty sure there is no way to turn a bunch of arbitrary SQL statements into an ADO.net DataSet without running the SQL commands through a database engine that understands the SQL in the dump file. You can't even do it between databases, e.g. a MySQL dump file will not run on an MS SQL server


You don't have to go manual, once you know the format. Creating a DataSet can be done 2 ways:

  1. Set up code to loop the file and create a dataset directly
  2. Set up code to loop the file and create an XML document in dataset format

Either will work. The best depends on your familiarity with the above (HINT: If you have no familiarity with either, choose the dataset).

It is all a question of format. What type of database is the DUMP file from? MySQL? Postgress? other?

0

精彩评论

暂无评论...
验证码 换一张
取 消