5 pts.
 How to fill Combo Box at runtime in VB 6.0 …I’ve used RecordSet object but rec.count of rs obj returns (-1).I hv enough data in the DB
[Private Sub Form_Load() FillCombo End Sub Sub FillCombo() Dim rs As New ADODB.Recordset, SQL As String SQL = "Select Spare_Name from Spare" rs.Open SQL, Conn, adOpenDynamic, adLockOptimistic Dim i As Integer For i = 1 To rs.RecordCount cboSpare.AddItem rs("Spare_Name") rs.MoveNext Next MsgBox "Successss", vbOKOnly End Sub]

Software/Hardware used:
ASKED: December 6, 2008  7:49 PM
UPDATED: December 8, 2008  8:31 PM

Answer Wiki:
From the <a href="http://msdn.microsoft.com/en-us/library/ms676701(VS.85).aspx">RecordCount Property (ADO) Documentation</a>: <i><b>"... The property returns -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount."</b></i> It could be better to use the <a href="http://msdn.microsoft.com/en-us/library/ms675787(VS.85).aspx">EOF Property</a> to check whether you still have records to process, since RecordCount will not always help you with that. When the data source returns no records, the provider sets both the BOF and EOF properties to True, so you can use that to check if the recordset is really empty.
Last Wiki Answer Submitted:  December 8, 2008  8:31 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _