Public DB As New ADODB.Connection'Public DB As ADODB.Connection
'Set DB = New ADODB.Connection
Dim adoTable As New ADODB.Recordset
Dim strCnnString, strSQLCommand As String
Dim modify As BooleanPrivate Sub cmdFirst_Click()
    adoTable.MoveFirst
    ShowFields
End SubPrivate Sub Form_Load()
strCnnString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
                & "Persist Security Info=False;Initial Catalog=DemoData;" _
                & "Data Source=(local)"
DB.ConnectionString = strCnnString
DB.open strCnnString, "sa", "", -1
With DB
     If .State = adStateClose Then
            .mode = adModeReadWrite
            .open strCnnString
    End If
End With
strSQLCommand = "Select * from Employee"
adoTable.open strSQLCommand, DB, 3, 3
ShowFields
modify = True
End Sub
Private Sub ShowFields()
    If (Not adoTable.EOF) And (Not adoTable.BOF) Then
        txtId = adoTable.Fields("Emp_Id")
        txtName = adoTable.Fields("Emp_Name")
        txtSex = adoTable.Fields("sex")
    End If
End Sub