2016-09-06 76 views

回答

0

简短的回答是肯定的,这是可能的。你需要使用代码有点像下面:

Sub ConnectionExample6() 
    Dim cnn As ADODB.Connection 
    Dim rs As ADODB.Recordset 

    Set cnn = New ADODB.Connection 

    ' Open a connection by referencing the ODBC driver. 
    cnn.ConnectionString = "driver={SQL Server};" & _ 
     "server=MySqlServer;uid=MyUserName;pwd=MyPassword;database=pubs" 
    cnn.Open 

    ' Create a Recordset by executing an SQL statement. 
    Set rs = cnn.Execute("Select * From authors") 

    ' Show the first author. 
    MsgBox rs("au_fname") & " " & rs("au_lname") 

    ' Close the connection. 
    rs.Close 

End Sub 

来源是在这里:

https://msdn.microsoft.com/en-us/library/ms807027.aspx

尝试使用这个,然后回来告诉我们,如果你有问题。

相关问题