property Record.DataSource as Object
Retrieves or sets a value that indicates the data source for object.

TypeDescription
Object An Object that defines the control's data. Currently, the control supports ADO.Recordset, ADODB.Recordset objects, DAO recordsets
use the DataSource property to bind a recordset to a control. The DataSource property clears the editors collection and add a new editor for each field found in the recordset. The Key property specifies the field's name. The Value property is updated as soon as the  cursor is moving in the recordset. Use the Refresh method to update the values for the editors, in case an DAO recordset is used. The EditType property specifies the type of the editor being inserted. For instance, if the recordset includes a Date/Time field editor, the EditType property is set to DateType. Use the AddItem or InsertItem methods to add new predefined values to a drop down list editor. Use the Item property to access an editor giving its key. Use the Visible property to hide an editor. Use the Add method to add new editors to the control. The Change event is called when the uses changes the value for an editor. If the control is bounded to a recordset, the value of the field is automatically updated in the recodset too. The LastError property gets the description of the last error, if occurs.

The following VB sample binds the "Employees" table in the "NWIND.MDB" database to the component, using an ADODB recordset:

Dim rs As Object, strNWIND As String
strNWIND = "D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "Employees", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strNWIND, 3, 3 ' Opens the table using static mode
With Record1
    .BeginUpdate
     Set .DataSource = rs
    With .Item("ReportsTo")
        .EditType = DropDownListType
        Dim i As Long
        i = 1
        .AddItem 0, "- <b>unspecified</b> -"
        While Not rs.EOF
            .AddItem rs("EmployeeID").Value, rs("FirstName").Value & " <b>" & rs("LastName").Value & "</b>"
            i = i + 1
            rs.MoveNext
        Wend
        rs.MoveFirst
    End With
    .EndUpdate
End With

The following VC sample binds the "Employees" table in the "NWIND.MDB" database to the component, using an ADODB recordset:

#import  rename ( "EOF", "adoEOF" )
using namespace ADODB;

BOOL isInstalled(BSTR strProgID, IDispatch** ppObject )
{
	CLSID clsid = CLSID_NULL;
	HRESULT hResult = E_POINTER;
	if (SUCCEEDED( hResult = CLSIDFromProgID( strProgID, &clsid ) ))
	{
		IDispatch* pObject = NULL;
		if ( SUCCEEDED( hResult = CoCreateInstance( clsid, NULL, CLSCTX_ALL, IID_IDispatch, reinterpret_cast(&pObject) ) ) )
		{
			if ( ppObject )
				(*ppObject = pObject)->AddRef();
			pObject->Release();
			return TRUE;
		}
	}
	return FALSE;
}

	COleVariant vtMissing; vtMissing.vt = VT_ERROR;
	CString strDatabase = "D:\\Program Files\\Microsoft Visual Studio\\VB98\\NWIND.MDB";
	
	CString strError = "";
	IDispatch* pObject = NULL;
	if ( isInstalled( L"ADODB.Recordset", &pObject ) )
	{
		_RecordsetPtr spRecordSet;
		if ( spRecordSet = pObject )
		{
			CString strConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ");
			strConnection += strDatabase;
			try
			{
				if ( SUCCEEDED( spRecordSet->Open( v("Employees"), v(strConnection), adOpenStatic, adLockOptimistic, 0 ) ) )
				{
					CEditor editor; 

					m_record.BeginUpdate();
					m_record.SetLabelSize(96);
					m_record.SetHBorderField( 6 );
					m_record.SetDataSource( spRecordSet );

					editor = m_record.GetItem(v("ReportsTo"));
					editor.SetEditType( /*DropDownListType*/ 3 );
					editor.AddItem(0, "- unspecified -", vtMissing );
					while ( !spRecordSet->adoEOF )
					{
						CString strName = V2S( &spRecordSet->Fields->GetItem( v("FirstName") )->Value );
						strName += " ";
						strName += V2S( &spRecordSet->Fields->GetItem( v("LastName") )->Value );;
						editor.AddItem( spRecordSet->Fields->GetItem( v("EmployeeID") )->Value, strName, vtMissing );
						spRecordSet->MoveNext();
					}
					spRecordSet->MoveFirst();
					m_record.EndUpdate();
				}
			}
			catch (...)
			{
				strError = "The sample database is missing. The 'SAMPLE.MDB' file is not found, or doesn't contain an 'Employees' table.";
			};
		}
		pObject->Release();
	}
	else
		strError = "Microsoft ADODB namepsace, 'MSADO15.DLL' file is not installed. ";