Free to do nothing, just to do a common demo, also convenient for later review
Look first.
The main problem in the middle is getting all the databases under the current connection and all the tables under the database
I looked it up on the Internet and found the following method
The first is to establish a connection
New SqlConnection ( string.format ("Data source={0};initial catalog=master; User Id={1}; PWD={2}", _host, _username, _pwd));
Please note that Catalog=master
Then use the following SQL to get all the databases
var New SqlDataAdapter ("select name from Master". sysdatabases", _connmaster);
And then want to get all the tables under a database
First establish a connection to this database
New SqlConnection ( string.format ("Data source={0};initial catalog={1}; User id={2}; PWD={3}", _host, dbname, _username, _pwd));
Then query it with the following SQL
var " select * from sysobjects ";
And then you get all the table names.
The next step is to start importing the exported data.
At this time to recommend a more commonly used Npio components, the demo program Baidu a search on OK
The following is attached to our source code click here to download
WinForm do Excel import and export the database