1、VB6連接SQLSERVER2014:
Dim Con As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub Form_Load()
Con.ConnectionString = "Driver={sql server};server=192.168.1.104;uid=sa;pwd=;database=db_2008"
Con.Open
Rs.Open "select * from test", Con, adOpenKeyset, adLockOptimistic
Set ms1.DataSource = Rs
Con.Close
End Sub
2、excel2013連接SQLSERVER2014:
Private Sub CommandButton1_Click()
Dim Con As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Con.ConnectionString = "Driver={sql server};server=wjpc;uid=sa;pwd=;database=db_2008"
Con.Open
Cells(1, 1).CopyFromRecordset Con.Execute("select * from aa")
Con.Close
End Sub
3、總結:"server="用來控制服務器