-3

如何使用 Mac Excel 2011 net.VB 从 MySQL 服务器读取数据和发送数据?

提前致谢 !

4

1 回答 1

0

资料来源:http ://bit.ly/Qfqvwb

  1. 从 mysql 安装 3.5.1 odbc 驱动程序:http: //dev.mysql.com/downloads/connector/odbc/3.51.html(轻松点击点击)
  2. 设置 ODBC 连接

    Private Sub btnTestReadInMysqlData_Click()
    
    Dim objDB, arrRecord, strRecord, strOutput
    Dim oRS, nRec, oFld
    Dim row
    
    'Database connection & select all from Table
    Set objDB = DBConnect()
    Set oRS = objDB.Execute("SELECT * FROM members")
    
    'Dump Records from Table
    nRec = 0
    row = 1
    Do While Not oRS.EOF
      For Each oFld In oRS.Fields
    
        'WScript.Echo oFld.Name & " = " & oFld.Value
    
        Worksheets("Tabelle1").Cells(row, 1).Value = oFld.Value
    
        'increment
        row = row + 1
    
      Next
      oRS.MoveNext
    Loop
    
    End Sub
    
    
    Function DBConnect()
    Set objDB = CreateObject("ADODB.Connection")
    objDB.Open "websitedata"
    Set DBConnect = objDB
    End Function
    
于 2012-10-11T15:19:42.040 回答