Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Access|excel|mysql two. VB Program of Guide Library
This project to use some object library, in the database access, decided to use ADO (ActiveX Data Objects), for the use of ASP, the name should be very familiar with, in fact, it in the application of VB is almost the same, because to operate Excel, Also refer to an Extended object library. Click "Project"---"References" in the Point menu, select "Microsoft ActiveX Data Objects 2.6 Library" and "Microsoft Excel 9.0 Object Library", in the list of references, The version of the referenced object library may be different, so choose the latest version of the same. To use dialog boxes and progress bars, and to refer to some parts, "engineering" in a la carte--"parts", select "Microsoft Common Dialog Control 6.0 (SP3)" and "Microsoft Windows Common Controls 6.0 (SP3) ".
The interface is shown in Figure one
The controls represented by the numbers in the figure are:
1-3:3 are TextBox controls, with the name mdbfilename,mdbpassword,xlsfilename,mdbfilename used to indicate the path and file name of the import Access file. Mdbpassword The password used to enter the Access file, Xlsfilename to indicate the path and filename of the import Excel file;
4: The name is Select_mdbfile,commandbutton control, used to select the Access file to import;
5: Name is Importmdb,commandbutton control, after selecting good file, use this button to import MDB file
6: Name is Commondialog1,commondialog control
7: The name is Select_xlsfile,commandbutton control, used to select the Excel file to import;
8: The name is Importxls,commandbutton control, select Good file, use this button to import XLS file;
9: Name is Commondialog2,commondialog control
10: Name is PrgBar1, progress bar (ProgressBar), when you want to import many records, use the progress bar to indicate the current import progress
11: The name is StatusBar1, status bar (StatusBar), indicating the progress status of the import, including "Import", "import complete" and so on.
To set the style to "1-sbrsimple"
Make the following statement on the head of the program
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, "'", "\")
Double-click the form to enter the following code when the form is loaded
Private Sub Form_Load ()
' Set the progress bar to invisible
Prgbar1.visible = False
' Connect MySQL database, pwd for database password, UID is username, DSN is the name of data source
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.