Re: Any Recordset stays empty when using SQL Native Client
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Thu, 9 Nov 2006 08:33:02 -0600
"Predius" <Predius@xxxxxxxxxxxxxx> wrote in message
news:uwgpxXABHHA.5060@xxxxxxxxxxxxxxxxxxxxxxx
I
<snipped>
Hi Ralph
The Code segment was copied from Microsoft :
http://msdn2.microsoft.com/en-us/library/ms130978.aspx
Don't blame me for their poor code (As New Declares) :-)
Back to topic:
Even the UDL Dialogue produces parameter names with spaces, but that's not
the point. I made a simple application with one DataEnvironment and a Grid
using the DE as Datasource. This worked fine as I used the UDL dialogue to
setup the connection to the server, the grid was populated with data. Then
copied exactely the same Connectionstring from that DE into my otherthe
Application. Additionally I eliminated the "As New" declares.
No luck so far, the problem persists. The Errors Collection is empty and
Recordset.Recordcount is -1. I can see that the Recordset.Fields are
populated with the correct fields from the table and they contain the data
of the first record. But the Recordset.Recordcount is -1.
Yeah. MS sample code is seldom examples of best coding practice, but in
their defense the code is more for illustration of a specific point and
never to meant to be production code. (Or at least I hope so. <g>0
Thanks of testing out the parameter 'names'. I once got burned using spaces
(or thought I did) and have since been somewhat anal about it. Nice to learn
it likely isn't that big a deal.
The problem is expecting the RecordCount to always 'work'. Whether or not
you get a count will depend on the cursor type you are using, and whether it
is client-side or server-side.
You need to use a client-side cursor, or a server-side with static, keyset,
or dynamic cursors. You can also use a simple .MoveLast .MoveFirst (not on a
ForwardOnly of course)
But it is probably better that you don't just rearrange the cursors to get a
recordcount. Other performance/Lock issues may require a particular
combination. Instead, determine if you really need a RecordCount or can't
retrieve it in a different way.
hth
-ralph
.
- References:
- Prev by Date: Re: Any Recordset stays empty when using SQL Native Client
- Next by Date: Re: Any Recordset stays empty when using SQL Native Client
- Previous by thread: Re: Any Recordset stays empty when using SQL Native Client
- Next by thread: Re: Any Recordset stays empty when using SQL Native Client
- Index(es):
Relevant Pages
|
|