Private Sub Command1_Click()
On Error Resume Next
Dim objConn As ADODB.Connection
Dim objRs As ADODB.Recordset
Set objConn = New ADODB.Connection
Set objRs = New ADODB.Recordset
objConn.ConnectionString = "Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=Test;Data Source=PC-20190830UKXS\SQL2014"
objConn.Open
objRs.CursorLocation = adUseClient
objRs.Open "Select * from Company", objConn, adOpenStatic, adLockReadOnly
Set DataGrid1.DataSource = objRs
If Err.Number <> 0 Then
MsgBox Err.Description
End If
On Error GoTo 0
End Sub