RecordsAffected from query as connection method

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default RecordsAffected from query as connection method

    Database: Access 2000
    MDAC Version: 2.7
    Provider: Microsoft.Jet.OLEDB.4.0

    Is there a way to access the number of records affected when executing a
    query as a method of the connection object? For example, using the
    Execute method of the connection I do the following:

    sql = _
    "EXEC spInsertActivityLog " &_
    "@prmStart='2003-07-02 09:00'," &_
    "@prmEnd='2003-07-02 10:00'," &_
    "@prmActivity='Breakfast'"
    conn.Execute sql, ra, &H81
    Response.Write ra & " records were affected."

    Using the query as a connection method I do the following:

    conn.spInsertActivityLog _
    "2003-07-02 09:00",_
    "2003-07-02 10:00",_
    "Breakfast"
    Response.Write ??? & " records were affected."

    The reason I ask is because in this situation, spInsertActivityLog only
    inserts the record if it does not overlap existing data. This is one of
    those rare cases where transactions are not sufficient to accomplish
    what I'm after. I'm perfectly happy to continue using method 1, but if
    possible I'd like to take advantage of method 2 since it does the
    parameter data typing for me. Any insight is appreciated.

    -Chris



    Chris Hohmann Guest

  2. Similar Questions and Discussions

    1. .Recordsaffected or @@RowCount
      Is there a way in native ColdFusion, without going through a SQL Server stored procedure, to get the number of records affected by an UPDATE stmt?...
    2. when to use connection method over disconnected recordsets
      When if ever should you use a connected recordset. I am using disconnected recordsets throughout my site as they are quicker, and after learning...
    3. Stored Proc as native connection object method
      I'm having difficulty making a stored procedure with multiple input parameters work as a native method of the connection object. The only way I...
    4. [PHP] Lost Connection to MySQL server during query
      Are you using mysql_pconnect or just mysql_connect? Donald Tyler wrote:
    5. Should I close a connection in a dispose method?
      I've built a class to broker the data in may application. In other words, when my business logic needs a list of widgets in the db, it calls...
  3. #2

    Default Re: RecordsAffected from query as connection method

    I have never seen the ability to specify the "query" as a method of the
    connection object. It's not listed here in the docs:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdaobj01_8.asp?frame=true[/url]

    Do you have any links on how this works?

    Cheers
    Ken

    "Chris Hohmann" <hohmannATyahooDOTcom> wrote in message
    news:OmwIpzcQDHA.3796@tk2msftngp13.phx.gbl...
    : Database: Access 2000
    : MDAC Version: 2.7
    : Provider: Microsoft.Jet.OLEDB.4.0
    :
    : Is there a way to access the number of records affected when executing a
    : query as a method of the connection object? For example, using the
    : Execute method of the connection I do the following:
    :
    : sql = _
    : "EXEC spInsertActivityLog " &_
    : "@prmStart='2003-07-02 09:00'," &_
    : "@prmEnd='2003-07-02 10:00'," &_
    : "@prmActivity='Breakfast'"
    : conn.Execute sql, ra, &H81
    : Response.Write ra & " records were affected."
    :
    : Using the query as a connection method I do the following:
    :
    : conn.spInsertActivityLog _
    : "2003-07-02 09:00",_
    : "2003-07-02 10:00",_
    : "Breakfast"
    : Response.Write ??? & " records were affected."
    :
    : The reason I ask is because in this situation, spInsertActivityLog only
    : inserts the record if it does not overlap existing data. This is one of
    : those rare cases where transactions are not sufficient to accomplish
    : what I'm after. I'm perfectly happy to continue using method 1, but if
    : possible I'd like to take advantage of method 2 since it does the
    : parameter data typing for me. Any insight is appreciated.
    :
    : -Chris
    :
    :
    :


    Ken Schaefer Guest

  4. #3

    Default Re: RecordsAffected from query as connection method

    Not that I'm aware of. This technique (2) is only useful if you don't need
    any of the functionality provided by a Command object beyond the execution
    of the procedure. If you need records affected (or return or output
    parameters), then you need to use either an explicit command object, or the
    implicit one utilized by the connection object's execute method.

    Bob Barrows

    Chris Hohmann wrote:
    > Database: Access 2000
    > MDAC Version: 2.7
    > Provider: Microsoft.Jet.OLEDB.4.0
    >
    > Is there a way to access the number of records affected when
    > executing a query as a method of the connection object? For example,
    > using the Execute method of the connection I do the following:
    >
    > sql = _
    > "EXEC spInsertActivityLog " &_
    > "@prmStart='2003-07-02 09:00'," &_
    > "@prmEnd='2003-07-02 10:00'," &_
    > "@prmActivity='Breakfast'"
    > conn.Execute sql, ra, &H81
    > Response.Write ra & " records were affected."
    >
    > Using the query as a connection method I do the following:
    >
    > conn.spInsertActivityLog _
    > "2003-07-02 09:00",_
    > "2003-07-02 10:00",_
    > "Breakfast"
    > Response.Write ??? & " records were affected."
    >
    > The reason I ask is because in this situation, spInsertActivityLog
    > only inserts the record if it does not overlap existing data. This is
    > one of those rare cases where transactions are not sufficient to
    > accomplish what I'm after. I'm perfectly happy to continue using
    > method 1, but if possible I'd like to take advantage of method 2
    > since it does the parameter data typing for me. Any insight is
    > appreciated.
    >
    > -Chris


    Bob Barrows Guest

  5. #4

    Default Re: RecordsAffected from query as connection method

    It's on this page near the end:
    [url]http://msdn.microsoft.com/library/en-us/ado270/htm/mdaobj01_7.asp[/url]

    Bob Barrows

    Ken Schaefer wrote:
    > I have never seen the ability to specify the "query" as a method of
    > the
    > connection object. It's not listed here in the docs:
    >
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdaobj01_8.asp?frame=true[/url]
    >
    > Do you have any links on how this works?
    >
    > Cheers
    > Ken
    >
    > "Chris Hohmann" <hohmannATyahooDOTcom> wrote in message
    > news:OmwIpzcQDHA.3796@tk2msftngp13.phx.gbl...
    >> Database: Access 2000
    >> MDAC Version: 2.7
    >> Provider: Microsoft.Jet.OLEDB.4.0
    >>
    >> Is there a way to access the number of records affected when
    >> executing a
    >> query as a method of the connection object? For example, using the
    >> Execute method of the connection I do the following:
    >>
    >> sql = _
    >> "EXEC spInsertActivityLog " &_
    >> "@prmStart='2003-07-02 09:00'," &_
    >> "@prmEnd='2003-07-02 10:00'," &_
    >> "@prmActivity='Breakfast'"
    >> conn.Execute sql, ra, &H81
    >> Response.Write ra & " records were affected."
    >>
    >> Using the query as a connection method I do the following:
    >>
    >> conn.spInsertActivityLog _
    >> "2003-07-02 09:00",_
    >> "2003-07-02 10:00",_
    >> "Breakfast"
    >> Response.Write ??? & " records were affected."
    >>
    >> The reason I ask is because in this situation, spInsertActivityLog
    >> only
    >> inserts the record if it does not overlap existing data. This is one
    >> of
    >> those rare cases where transactions are not sufficient to accomplish
    >> what I'm after. I'm perfectly happy to continue using method 1, but
    >> if
    >> possible I'd like to take advantage of method 2 since it does the
    >> parameter data typing for me. Any insight is appreciated.
    >>
    >> -Chris


    Bob Barrows Guest

  6. #5

    Default Re: RecordsAffected from query as connection method

    Cool, never seen that before (well, maybe seen it - I've look at that page
    enough times! - never paid any attention I suppose)

    Thanks Bob.

    Cheers
    Ken

    "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    news:OR2duXdQDHA.304@tk2msftngp13.phx.gbl...
    : It's on this page near the end:
    : [url]http://msdn.microsoft.com/library/en-us/ado270/htm/mdaobj01_7.asp[/url]
    :
    : Bob Barrows
    :
    : Ken Schaefer wrote:
    : > I have never seen the ability to specify the "query" as a method of
    : > the
    : > connection object. It's not listed here in the docs:
    : >
    :
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdaobj01_8.asp?frame=true[/url]
    : >
    : > Do you have any links on how this works?
    : >
    : > Cheers
    : > Ken
    : >
    : > "Chris Hohmann" <hohmannATyahooDOTcom> wrote in message
    : > news:OmwIpzcQDHA.3796@tk2msftngp13.phx.gbl...
    : >> Database: Access 2000
    : >> MDAC Version: 2.7
    : >> Provider: Microsoft.Jet.OLEDB.4.0
    : >>
    : >> Is there a way to access the number of records affected when
    : >> executing a
    : >> query as a method of the connection object? For example, using the
    : >> Execute method of the connection I do the following:
    : >>
    : >> sql = _
    : >> "EXEC spInsertActivityLog " &_
    : >> "@prmStart='2003-07-02 09:00'," &_
    : >> "@prmEnd='2003-07-02 10:00'," &_
    : >> "@prmActivity='Breakfast'"
    : >> conn.Execute sql, ra, &H81
    : >> Response.Write ra & " records were affected."
    : >>
    : >> Using the query as a connection method I do the following:
    : >>
    : >> conn.spInsertActivityLog _
    : >> "2003-07-02 09:00",_
    : >> "2003-07-02 10:00",_
    : >> "Breakfast"
    : >> Response.Write ??? & " records were affected."
    : >>
    : >> The reason I ask is because in this situation, spInsertActivityLog
    : >> only
    : >> inserts the record if it does not overlap existing data. This is one
    : >> of
    : >> those rare cases where transactions are not sufficient to accomplish
    : >> what I'm after. I'm perfectly happy to continue using method 1, but
    : >> if
    : >> possible I'd like to take advantage of method 2 since it does the
    : >> parameter data typing for me. Any insight is appreciated.
    : >>
    : >> -Chris
    :
    :
    :


    Ken Schaefer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139