Re: Any Recordset stays empty when using SQL Native Client




"Predius" <Predius@xxxxxxxxxxxxxx> wrote in message
news:uwgpxXABHHA.5060@xxxxxxxxxxxxxxxxxxxxxxx

<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
I
copied exactely the same Connectionstring from that DE into my other
Application. Additionally I eliminated the "As New" declares.

No luck so far, the problem persists. The Errors Collection is empty and
the
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



.



Relevant Pages

  • Re: Help with IIS server Error (Provider error 80040154 Class not registered)
    ... Mr. Barrows ... page on my ISP's web server. ... > determines whether or not the cursor supports recordcount. ...
    (microsoft.public.inetserver.asp.general)
  • Re: Please help with cmd.execute select SQL?
    ... > What is the proper format for my SQL str using command.execute? ... RecordCount requires the use of an expensive cursor. ... and connection immediately, releasing the connection back to the connection ...
    (microsoft.public.inetserver.asp.general)
  • Re: ADO Record Count Issue
    ... Your dynamic cursor allows for runtime updates so it can not determine the ... RecordCount a lot and all of those queries use adOpenStatic for the cursor ... and then the the information is pushed on to an Excel ...
    (microsoft.public.vsnet.debugging)
  • Re: recordcount = -1 ??
    ... You don't need to use Recordcount, ... cursor, ... Looping through an array is much more efficient than looping through a ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)
  • nested cursor declarations through dynamic sql
    ... I need to get a list of file names from an Excel spreadsheet. ... declared a cursor that uses opendatasourceto get the file names out ... parameters is to use dynamic SQL, so I am currently building an sql ... statement that declares a cursor that selects the data from the xls ...
    (microsoft.public.sqlserver.programming)