回复 2楼 xyxcc177
Private Sub CommandButton1_Click()Dim cn, rs As Object
Dim strCon As String
Dim sql As String
Set cn = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
strCon = "provider=sqloledb;data source=127.0.0.1;User id=sa;database=myData"
cn.Open strCon
sql = "selsect * from Table_1"
rs.Open sql, cn, 1, 3
sheet1.Range("a2").CopyFromRecordset rs
rs.Close
cn.Close
End Sub
还是有问题,能帮我改下吗?谢谢!