ADO help

ADO help

Anonymous
Not applicable
265 Views
4 Replies
Message 1 of 5

ADO help

Anonymous
Not applicable
this isn't related to autocad but this group is the only reliable vb source
i have.
why do i get an eof error in this code?

Do Until People.EOF Or People!Client = lstPeople.List(lstPeople.ListIndex)
People.MoveNext
Loop

shouldn't it just drop out if eof = true? i've checked the value of
people.eof and it is true but it won't drop out.


please help,
Rob
0 Likes
266 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
What happens if you remove the second part of your test?

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com


"Rob Tomson" wrote in message
news:476F8B4CE9E69CD4AF82A43BF4A02491@in.WebX.maYIadrTaRb...
> this isn't related to autocad but this group is the only reliable vb
source
> i have.
> why do i get an eof error in this code?
>
> Do Until People.EOF Or People!Client =
lstPeople.List(lstPeople.ListIndex)
> People.MoveNext
> Loop
>
> shouldn't it just drop out if eof = true? i've checked the value of
> people.eof and it is true but it won't drop out.
>
>
> please help,
> Rob
>
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
i can't remove the second part....what i have is a list box of clients and
when i click on the client then it pulls info from a database and popluates
text boxes, etc. if i remove the eof test then i'll get an error when i
create a new entry in the listbox


"Frank Oquendo" wrote in message
news:AE21266E4291C27E96DCC02EF42A2B57@in.WebX.maYIadrTaRb...
> What happens if you remove the second part of your test?
>
> --
> Good judgment comes from experience.
> Experience comes from bad judgment.
>
> http://www.acadx.com
>
>
> "Rob Tomson" wrote in message
> news:476F8B4CE9E69CD4AF82A43BF4A02491@in.WebX.maYIadrTaRb...
> > this isn't related to autocad but this group is the only reliable vb
> source
> > i have.
> > why do i get an eof error in this code?
> >
> > Do Until People.EOF Or People!Client =
> lstPeople.List(lstPeople.ListIndex)
> > People.MoveNext
> > Loop
> >
> > shouldn't it just drop out if eof = true? i've checked the value of
> > people.eof and it is true but it won't drop out.
> >
> >
> > please help,
> > Rob
> >
> >
>
>
0 Likes
Message 4 of 5

Anonymous
Not applicable
If you're retrieving information on the selected client, why use a
loop at all? A properly formed SQL statement will allow you to select
just the one record. This will be a lot quicker and easier to debug:

' Let's assume you already have a connection 'cn'
Dim rs As ADODB.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM ClientTable WHERE ClientID = " &
List1.ItemData(List1.ListIndex)
rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly
If Not (rs.BOF And rs.EOF) Then
' You have a record, do your thing
End If

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com


"Rob Tomson" wrote in message
news:678145EF8D38F9307CB1EF9563D31D20@in.WebX.maYIadrTaRb...
> i can't remove the second part....what i have is a list box of
clients and
> when i click on the client then it pulls info from a database and
popluates
> text boxes, etc. if i remove the eof test then i'll get an error
when i
> create a new entry in the listbox
0 Likes
Message 5 of 5

Anonymous
Not applicable
thanks! i'll try that.

"Frank Oquendo" wrote in message
news:2651B20EA6F660A7FA545BC053E54954@in.WebX.maYIadrTaRb...
> If you're retrieving information on the selected client, why use a
> loop at all? A properly formed SQL statement will allow you to select
> just the one record. This will be a lot quicker and easier to debug:
>
> ' Let's assume you already have a connection 'cn'
> Dim rs As ADODB.Recordset
> Dim strSQL As String
>
> strSQL = "SELECT * FROM ClientTable WHERE ClientID = " &
> List1.ItemData(List1.ListIndex)
> rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly
> If Not (rs.BOF And rs.EOF) Then
> ' You have a record, do your thing
> End If
>
> --
> Good judgment comes from experience.
> Experience comes from bad judgment.
>
> http://www.acadx.com
>
>
> "Rob Tomson" wrote in message
> news:678145EF8D38F9307CB1EF9563D31D20@in.WebX.maYIadrTaRb...
> > i can't remove the second part....what i have is a list box of
> clients and
> > when i click on the client then it pulls info from a database and
> popluates
> > text boxes, etc. if i remove the eof test then i'll get an error
> when i
> > create a new entry in the listbox
>
>
0 Likes