Bind the DataGrid from database in VB 6

The following code snippet can be used for showing the data from the dataset into Datagrid control when you are working in vb 6.
We are using Datasource property of the DataGrid control for displaying the data. For it we get the Data from the database into ADODB recordset object. the program require to add the reference of the Microsoft Activex Data objects library so that you can use the ADODB.
See the example:

Private m_strCnn  As String
Private m_adoConn As ADODB.Connection
Private Sub SetData()
With m_adoConn
        If .State = 0 Then
        .Open m_strCnn
        End If
    End With
    Dim gridrs As New ADODB.Recordset
    With gridrs
        .ActiveConnection = m_adoConn
        .CursorLocation = adUseClient
        .CursorType = adOpenKeyset
        .LockType = adLockReadOnly
        .Source = "Select * from yourtable"
    End With
    Set DataFrid1.DataSource = gridrs
    Set gridrs = Nothing
End Sub