Home > Article > Backend Development > A method to migrate data from SQL Server 7.0 to MySQL_PHP Tutorial
How to migrate data from Microsoft SQL Server 7.0 to MySQL
Zhbforce
I guess everyone likes to use Word for typing, Excel for calculation and planning, and PowerPoint for slide presentation... But this only uses Office A very small part of the range of features. According to surveys, the vast majority of users only use 20% of the functions of Office products, and few people pay attention to Visual Basic for Application. In fact, being familiar with the functions of VBA can make your work twice the result with half the effort. Especially for accounting, finance and other majors, making a good set of macros can almost solve the problem once and for all! Recently, VBA functions have been added to AutoCAD, which cannot but be said to be a trend!
The function of VBA is not just for virus creators to cause trouble. The fact that VBA can be used to create viruses also illustrates its power and ease of use! Using ADO objects, you can perform database operations very conveniently! The following is a simple example of data exchange:
Since ADO objects do not directly support MySQL, MyODBC must be installed first. The latter is also a free product and can be downloaded from www.mysql.org. Once MyODBC is installed, You can configure a data source name in ODBC data source management and point it to the MySQL database you want to connect to. The code is as follows:
Sub connectMySQL()
'Connect to the MySQL database through MyODBC and transfer the data from Microsoft SQL Server 7
' 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 'Declare and create an object record set
Dim cm As New ADODB.Command 'Declare and create object commands
sConnect = "dsn=mysql1" 'Specify the data source name of MySQL
cnMySQL.Open sConnect 'Connect 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(70),softdesc blob," & _
"softpath varchar(30),softleng varchar(10),softclass varchar( 10),softsugest tinyint(1)," & _
"softdown smallint(4))" 'Create a new MySQL data table statement
sSql = "select * from softinfo order by softnum"
rs. Open sSql, cnMSSQL, 1, 1