Private Sub Command_Click()
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object
Dim myRecSet As New ADODB.Recordset 'Recordset Object
Dim sqlStr As String ' String variable to store sql command
MyConnObj.Open "Provider = sqloledb;" & "Data Source=JITENDRA-PC\SQLEXPRESS;" & "Initial Catalog=Test;"
sqlStr = "select * from Test"
myRecSet.Open sqlStr, MyConnObj, adOpenKeyset
MsgBox "Total Number of records = " & myRecSet.RecordCount
MyConnObj.Close
End Sub