Spent whole night failing to count 2 records

Discussion in 'ASP .Net' started by Didier Chesto, Jan 26, 2010.

  1. Since I use Dreamweaver 8, all recordsets are opened by rs_cmd.Execute().
    The problem is that rs.RecordCount() doesn't work anymore. I found a number
    of solutions that I cannot get to work.

    Solution 1. I have to use the forward only cursor but I don't know how to
    do that. I do know how to do that with the 'old' rs.Open() way but this way
    I cannot have the convenience anymore of dragging columns in my code.

    Solution 2. So I tried counting the records by iteration in a loop until
    EOF. Works. The only thing is I cannot rewind the recordset anymore:
    rs.MoveFirst() doesn't work.

    Solution 3. I don't want to create a separate recordset to count via SQL
    for reasons of database load.

    Solution 4. Getrows(). Sounds interesting because you get out of the
    database a.s.a.p. and use the data from an array. But there's my other
    handicap: I program in ASP Javascript, not VBScript. I cannot find a good
    example of using Getrows() in Javascript.

    Funny how you can spend all night on something simple like counting records
    and still don't get it to work. If anybody can help me out, my thanks would
    reach rabies-like levels.
    --
    Everything I do is either illegal, immoral, or fattening.
    (W.C. Fields)
     
    Didier Chesto, Jan 26, 2010
    #1
    1. Advertising

  2. Didier Chesto

    Scott M. Guest

    How about using ASP .NET and ADO.NET instead of Dreamweaver and Classic ADO,
    where there is no such thing as a RecordSet?

    -Scott



    "Didier Chesto" <> wrote in
    message news:1esfesg4a22i3$...
    > Since I use Dreamweaver 8, all recordsets are opened by rs_cmd.Execute().
    > The problem is that rs.RecordCount() doesn't work anymore. I found a
    > number
    > of solutions that I cannot get to work.
    >
    > Solution 1. I have to use the forward only cursor but I don't know how to
    > do that. I do know how to do that with the 'old' rs.Open() way but this
    > way
    > I cannot have the convenience anymore of dragging columns in my code.
    >
    > Solution 2. So I tried counting the records by iteration in a loop until
    > EOF. Works. The only thing is I cannot rewind the recordset anymore:
    > rs.MoveFirst() doesn't work.
    >
    > Solution 3. I don't want to create a separate recordset to count via SQL
    > for reasons of database load.
    >
    > Solution 4. Getrows(). Sounds interesting because you get out of the
    > database a.s.a.p. and use the data from an array. But there's my other
    > handicap: I program in ASP Javascript, not VBScript. I cannot find a good
    > example of using Getrows() in Javascript.
    >
    > Funny how you can spend all night on something simple like counting
    > records
    > and still don't get it to work. If anybody can help me out, my thanks
    > would
    > reach rabies-like levels.
    > --
    > Everything I do is either illegal, immoral, or fattening.
    > (W.C. Fields)
     
    Scott M., Jan 26, 2010
    #2
    1. Advertising

  3. Op Tue, 26 Jan 2010 02:26:47 -0000 schreef Mark Rae [MVP]:

    > "Didier Chesto" <> wrote in
    > message news:1esfesg4a22i3$...
    >
    >> Since I use Dreamweaver 8

    >
    > You might get a better by response posting in a Dreamweaver newsgroup /
    > forum - I don't think I've ever seen a Dreamweaver question in here
    > before...


    Dreamweaver is not the source of the problem. If I would code it manually,
    I'd have the same problems. If I may cut it down, this is the problem.

    var rs_cmd=Server.CreateObject ("ADODB.Command");
    rs_cmd.ActiveConnection = MM_database_STRING;
    rs_cmd.CommandText="SOME SQL";
    rs_cmd.Prepared = true;
    var rs = rsClicks_cmd.Execute();

    - rs.RecordCount() doesn't work
    - rs.MoveFirst() doesn't work
    - create rsCount with some sql with a Count(...) statement is not
    preferred, the database shouldn't be stressed just to count records
    - rs.GetRows() I don't understand because I only find VBScript examples

    So what I did as a workaround meanwhile is to iterate through the records,
    count them /and/ put the data in an array I understand (much like GetRows I
    assume). It works, but not very elegant.

    --
    Everything I do is either illegal, immoral, or fattening.
    (W.C. Fields)
     
    Didier Chesto, Jan 26, 2010
    #3
  4. Op Mon, 25 Jan 2010 21:34:59 -0500 schreef Scott M.:

    > How about using ASP .NET and ADO.NET instead of Dreamweaver and Classic ADO,


    Totally true. I'm in the process of hiring a professional with the latest
    skills. Until then I try to cope myself with programming techniques I
    learnt in the 80's (I got away with that for too long :-D)

    > where there is no such thing as a RecordSet?


    You mean there's no recordset in Classic ADO?
    --
    Everything I do is either illegal, immoral, or fattening.
    (W.C. Fields)
     
    Didier Chesto, Jan 26, 2010
    #4
  5. Didier Chesto

    Scott M. Guest

    "Didier Chesto" <> wrote in
    message news:1k7adbzm617af$.1w17dw68ot44w$...
    > Op Mon, 25 Jan 2010 21:34:59 -0500 schreef Scott M.:
    >
    >> How about using ASP .NET and ADO.NET instead of Dreamweaver and Classic
    >> ADO,

    >
    > Totally true. I'm in the process of hiring a professional with the latest
    > skills. Until then I try to cope myself with programming techniques I
    > learnt in the 80's (I got away with that for too long :-D)
    >
    >> where there is no such thing as a RecordSet?

    >
    > You mean there's no recordset in Classic ADO?


    No, the sentence was "How about using ASP .NET and ADO.NET instead of
    Dreamweaver and Classic ADO,
    where there is no such thing as a RecordSet?" ADO .NET does not have a
    Recordset - it's obsolete.

    I think you'll find that using COM objects (recordset) in a .NET
    application, will actually cause the performance of the application to
    degrade. Unless you have a specific reason to be using the recordset, you
    shouldn't be using it at all.

    -Scott
     
    Scott M., Jan 26, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob
    Replies:
    31
    Views:
    1,035
    Nick Malik
    Jul 16, 2004
  2. Dan
    Replies:
    0
    Views:
    373
  3. Replies:
    5
    Views:
    597
    Laurent Bugnion
    Apr 26, 2006
  4. \A_Michigan_User\
    Replies:
    2
    Views:
    923
    \A_Michigan_User\
    Aug 21, 2006
  5. 0m
    Replies:
    1
    Views:
    323
Loading...

Share This Page