您好,请参考如下代码。
Private Sub Command1_Click()
If DataEnvironment1.Connection1.State = adStateOpen Then
DataEnvironment1.Connection1.Close
End If
DataEnvironment1.Connection1.Open
DataEnvironment1.Commands(1).ActiveConnection = DataEnvironment1.Connection1
DataEnvironment1.Commands(1).CommandText = "select top 1 * from 工资表 "
DataReport1.Show
DataReport1.Refresh
End Sub
Private Sub Command2_Click()
If DataEnvironment1.Connection1.State = adStateOpen Then
DataEnvironment1.Connection1.Close
End If
DataEnvironment1.Connection1.Open
DataEnvironment1.Commands(1).ActiveConnection = DataEnvironment1.Connection1
DataEnvironment1.Commands(1).CommandText = "select top 2 * from 工资表 "
DataReport1.Show
DataReport1.Refresh
End Sub