WinForm do Excel import and export the database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.