Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

ADO & VB6: MoveNext

Hi,

I'm developing an application in VB6 that integrates with my SQL Server 7.0 Database. So far, I've got a form that allows me to read from, write to and Add new records to my recordset. I've also included two little controls that are supposed to allow me to move back and forward through my recordset, populating my textboxes as I move through the entries. The only problem is, my "Next" command button (Using MoveNext) and my "Previous" (using MovePrevious) buttons only allow me to cycle through the first two records. Is there some code I'm missing or something I'm doing wrong? Any help would be appreciated.

(Code Sample for "cmdNext")

[I]Private Sub CmdNext_Click()
Dim mysql As String
mysql = "select * from prdProduct"

xcGetRecordSet rsprod, mysql, "ED"
If rsprod.EOF Then rsprod.MoveFirst Else rsprod.MoveNext
Set DataGrid1.DataSource = rsprod
txtName.Text = rsprod!ProductName
txtDesc.Text = rsprod!ProductDescription
txtQuantity = rsprod!QuantityOnHand
lblProdNum = rsprod!ProductKey

End Sub

Thanks,
Josh
[1208 byte] By [shadowkindred] at [2007-11-11 6:59:26]
# 1 Re: ADO & VB6: MoveNext
Hi Josh,

The main problem that I've sought on your coding, is that procedural programming. Once you reset or request again for a recordset, then it will only refresh your recordset and it will go back to the first record. You must have a static procedure.
spanner at 2007-11-11 17:27:43 >