Presumably everyone likes to use Word typing, calculate and plan with Excel, PowerPoint slides to show ..., but this only uses a small part of the Office family of features. According to the survey, most users use only 20% of the functionality of Office products, and few people notice visual Basic for application. In fact, familiar with the function of VBA can make your work more effective, especially for accounting, finance and other professional, make a good macro, almost can be done once and for all! Recently, AutoCAD has also added the functionality of VBA, which cannot be said to be a trend!
The functionality of VBA is never just for the virus maker to make trouble, and VBA can be used to create viruses while also explaining its powerful and easy-to-use features! The use of ADO objects, can be very convenient database operation! Here is an example of a simple data exchange:
Because ADO object does not directly support MySQL, so must first install MYODBC, the latter is a free product, download on www.mysql.org, installed MYODBC, you can configure a data source name in the ODBC data source management, Point it to the MySQL database you want to connect to. The code is as follows:
Sub Connectmysql ()
' Connect to the MySQL database via MYODBC, and Microsoft SQL Server 7
' data to be transferred into MySQL
Dim Sconnect As String, sSQL as String, I as Long
Dim Cnmssql as New ADODB. Connection
Dim Cnmysql as New ADODB. Connection
' Declare and create an object connection
Dim rs as New ADODB. Recordset ' declares and creates an object record set
Dim cm as New Adodb.command ' declares and creates object commands
Sconnect = "DSN=MYSQL1" ' specifies the data source name for MySQL
Cnmysql.open sconnect ' connected to MySQL
Sconnect= "Provider=SQLOLEDB.1; Persist Security Info=false; User id=sa;pwd=123456;initial catalog=softdown;data Source=ntserver "
' Connect to MS SQL Server 7
Cnmssql.open Sconnect
' sSQL = ' CREATE Table softinfo (softnum smallint,softname varchar, Softdesc blob, "& _
http://www.bkjia.com/PHPjc/631439.html www.bkjia.com true http://www.bkjia.com/PHPjc/631439.html techarticle Presumably everyone likes to use Word typing, calculate and plan with Excel, PowerPoint slides to show ..., but this only uses a small part of the Office family of features. ...