Home php教程 php手册 如何将Access和Excel导入到Mysql中之三

如何将Access和Excel导入到Mysql中之三

Jun 13, 2016 am 10:05 AM
access excel mysql one two use and how import Will project of program want this

二。导库的VB程序
  这个工程要使用一些对象库,在数据库访问方面,决定使用ADO(ActiveX Data Objects),对于使用过ASP的人,这个名字应该非常熟悉了,实际上,它在VB中的应用也是几乎一样的,由于要操作Excel,还要引用一个扩展的对象库。点菜单中的“工程”---“引用”,选择“Microsoft ActiveX Data Objects 2.6 Library”和“Microsoft Excel 9.0 Object Library”,在引用列表中,可引用对象库的版本或许有所不同,选择类似的最新版本就可以了。要使用对话框和进度条,还要引用一些部件,点菜单中的“工程”--“部件”,选择“Microsoft Common Dialog Control 6.0(SP3)”和“Microsoft Windows Common Controls 6.0(SP3)”。
 
界面如图一所示

图中各数字表示的控件分别是:
1-3:3个均为TextBox控件,名字分别为mdbfilename,mdbpassword,xlsfilename,mdbfilename用来指示导入Access文件的路径和文件名,mdbpassword用来输入Access文件的密码,xlsfilename用来指示导入Excel文件的路径和文件名;
4:名称为select_mdbfile,CommandButton控件,用来选择要导入的Access文件;
5:名称为importMDB,CommandButton控件,选择好文件后,用该按钮导入MDB文件
6:名称为CommonDialog1,CommonDialog控件
7:名称为select_xlsfile,CommandButton控件,用来选择要导入的Excel文件;
8:名称为importXLS,CommandButton控件,选择好文件后,用该按钮导入XLS文件;
9:名称为CommonDialog2,CommonDialog控件
10:名称为prgBar1,进度条(ProgressBar),当要导入很多记录时,使用进度条可以指示当前的导入进度
11:名称为StatusBar1,状态条(StatusBar),指示导入的进展状态,包括“正在导入”,“导入完成”等。
 
要将Style设置为“1-sbrSimple”

在程序的头部作以下声明
Option Explicit
Dim Cn As New ADODB.Connection
Dim Cnmysql As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Rsmysql As New ADODB.Recordset

Function replace_str(srcstr As String)
srcstr = Replace(srcstr, "", "")
replace_str = Replace(srcstr, "'", "'")
End Function

双击form,在装载form时输入以下的代码
Private Sub Form_Load()
'将进度条设置为不可见
prgBar1.Visible = False
'连接mysql数据库,pwd为数据库的密码,uid为用户名,dsn为数据源的名称
Cnmysql.ConnectionString = "uid=root;pwd=;dsn=build"
Cnmysql.Open
End Sub

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

Using Dicr/Yii2-Google to integrate Google API in YII2 Using Dicr/Yii2-Google to integrate Google API in YII2 Apr 18, 2025 am 11:54 AM

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko

What are the plugins for wordpress blocking ip What are the plugins for wordpress blocking ip Apr 20, 2025 am 08:27 AM

WordPress IP blocking plugin selection is crucial. The following types can be considered: based on .htaccess: efficient, but complex operation; database operation: flexible, but low efficiency; firewall: high security performance, but complex configuration; self-written: highest control, but requires more technical level.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

See all articles