SQL / ADO issue when upgrading to SQL 2000

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

  1. #1

    Default SQL / ADO issue when upgrading to SQL 2000

    Hi Folks,

    We recently upgraded to SQL 2000 from SQL 7. We run a Classic ASP based
    website using this server as the backend.

    We thought the migration went seamlessly - but it seems that INSERT
    statements that also return the identity column ID now don't work properly.
    For example (in ASP using ADO):-

    ---------------------------------------------------

    Set rsTest = dbConn.Execute("INSERT INTO tbTable (field1, field2)
    VALUES('test', 'test'); SELECT @@identity;").NextRecordset

    varNewID = rsTest(0)

    rsTest.Close
    Set rsTest = Nothing

    ---------------------------------------------------

    We've found a solution that works by setting NOCOUNT ON in the query and
    removing the .NextRecordSet from the ADO execution:-

    ---------------------------------------------------

    Set rsTest = dbConn.Execute("SET NOCOUNT ON; INSERT INTO tbTable (field1,
    field2) VALUES('test', 'test'); SELECT @@identity;")

    varNewID = rsTest(0)

    rsTest.Close
    Set rsTest = Nothing

    ---------------------------------------------------

    This works but all throughout our site the old method is used and it would
    involve a great deal of work to change every occurrence.

    Is there a setting or something we can apply in SQL 2000 to fix this issue??

    Any help much appreciated!!

    Rob



    TWiSTeD ViBE Guest

  2. Similar Questions and Discussions

    1. Access 2000 Data Viewing Issue
      I am running an application on ColdFusion MX7 server against an Access 2000 DB. There is a specific field within one of the tables that is setup as...
    2. Cannot create role after upgrading from Windows 2000 toWindows XP
      I had no problem until the computer on which resides the Administrator for Contribute 3 was upgraded from Windows 2000 to Windows XP. I can...
    3. cf 6.1 -- apache issue (windows 2000)
      Hi-- I have apache 2.0.48 running on windows server 2000-- coldfusion is also running on the server, MX 6.1. I am able to view .html pages but...
    4. CFMX6.0 and Exchange 2000 - SMTP issue
      We're using CF MX 6.0 and Exchange 2000 Server on the same machine. Exchange 2000 Server has been installed in a later timeframe and now we are...
    5. converting 2000 to 2003 issue is size
      Hi I am so tired by now and reach out for hel I have just upgraded from Publisher 2000 to Publisher 200 when i convert to html to upload to my...
  3. #2

    Default Re: SQL / ADO issue when upgrading to SQL 2000

    TWiSTeD ViBE wrote:
    > Hi Folks,
    >
    > We recently upgraded to SQL 2000 from SQL 7. We run a Classic ASP
    > based website using this server as the backend.
    >
    > We thought the migration went seamlessly - but it seems that INSERT
    > statements that also return the identity column ID now don't work
    > properly. For example (in ASP using ADO):-
    >
    > ---------------------------------------------------
    >
    > Set rsTest = dbConn.Execute("INSERT INTO tbTable (field1, field2)
    > VALUES('test', 'test'); SELECT @@identity;").NextRecordset
    >
    > varNewID = rsTest(0)
    >
    > rsTest.Close
    > Set rsTest = Nothing
    >
    > ---------------------------------------------------
    What does "doesn't work" mean? error message? No results?

    FWIW, I disapprove of this technique. Why aren't you encapsulating this code
    in stored procedures? Are you protecting yourself from SQL Injection?
    There's been much discussion on this subject in the past couple of weeks in
    the .asp.db newsgroup, so a quick Google search should get you plenty of
    info on this matter.
    >
    > We've found a solution that works by setting NOCOUNT ON in the query
    > and removing the .NextRecordSet from the ADO execution:-
    >
    > ---------------------------------------------------
    >
    > Set rsTest = dbConn.Execute("SET NOCOUNT ON; INSERT INTO tbTable
    > (field1, field2) VALUES('test', 'test'); SELECT @@identity;")
    >
    > varNewID = rsTest(0)
    >
    > rsTest.Close
    > Set rsTest = Nothing
    >
    > ---------------------------------------------------
    >
    > This works but all throughout our site the old method is used and it
    > would involve a great deal of work to change every occurrence.
    >
    > Is there a setting or something we can apply in SQL 2000 to fix this
    > issue??
    >
    There is, but I suggest you don't use it as someday somebody will be
    counting on the default behavior. However, from Books Online (BOL):

    *********************************************
    How to configure user options (Enterprise Manager)
    To configure user options
    Expand a server group.


    Right-click a server, and then click Properties.


    Click the Connections tab.


    In the Default connection options box, select one or more attributes to
    configure the default query-processing options for all connected users.
    By default, no user options are configured
    *******************************************

    Scroll down in the list box to set the nocount option.

    HTH,
    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  4. #3

    Default Re: SQL / ADO issue when upgrading to SQL 2000

    Just wanted to add:
    Even if you do shut off nocount for everyone, you are still going to have to
    get rid of all those ".NextRecordset"s. You should WANT to do this. Passing
    two recordsets across the network when one will do is extremely inefficient
    (using a recordset to return a single value is also inefficient, but that's
    another rant ...)

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  5. #4

    Default Re: SQL / ADO issue when upgrading to SQL 2000

    Thanks for the help...

    I was about to reply with what you've mentioned below - this solution
    doesn't really solve the issue.

    I also checked the old server and confirmed my thoughts - the NOCOUNT
    setting in the server preferences wasn't set there either.

    Another weird thing is that some of our other webservers that access the
    same backend don't have this issue - which implies it is something specific
    to the one connection - however the connection settings havent changed at
    all since the migration.

    Its all very annoying really!

    Any further thoughts?

    Rob


    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:%23OeN0%23Z5DHA.1804@TK2MSFTNGP12.phx.gbl...
    > Just wanted to add:
    > Even if you do shut off nocount for everyone, you are still going to have
    to
    > get rid of all those ".NextRecordset"s. You should WANT to do this.
    Passing
    > two recordsets across the network when one will do is extremely
    inefficient
    > (using a recordset to return a single value is also inefficient, but
    that's
    > another rant ...)
    >
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >

    TWiSTeD ViBE Guest

  6. #5

    Default Re: SQL / ADO issue when upgrading to SQL 2000

    TWiSTeD ViBE wrote:
    > Thanks for the help...
    >
    > I was about to reply with what you've mentioned below - this solution
    > doesn't really solve the issue.
    >
    > I also checked the old server and confirmed my thoughts - the NOCOUNT
    > setting in the server preferences wasn't set there either.
    Again, for the sake of efficiency, you should be wanting to go back and add
    the "SET NOCOUNT ON" line to all your code and remove the .NextRecordset. I
    know it seems like a daunting task (there are search and replace utilities
    out there that will help), but it will help the performance of all your
    apps.
    >
    > Another weird thing is that some of our other webservers that access
    > the same backend don't have this issue - which implies it is
    > something specific to the one connection - however the connection
    > settings havent changed at all since the migration.
    >
    > Its all very annoying really!
    >
    > Any further thoughts?
    Not until you tell us what "not working" means. :-)
    I suspectu you are seeing the effects of the new version of MDAC that was
    installed along with your SQL Server.


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  7. #6

    Default Re: SQL / ADO issue when upgrading to SQL 2000

    TWiSTeD ViBE wrote:
    > Thanks for the help...
    >
    > I was about to reply with what you've mentioned below - this solution
    > doesn't really solve the issue.
    >
    > I also checked the old server and confirmed my thoughts - the NOCOUNT
    > setting in the server preferences wasn't set there either.
    Again, for the sake of efficiency, you should be wanting to go back and add
    the "SET NOCOUNT ON" line to all your code and remove the .NextRecordset. I
    know it seems like a daunting task (there are search and replace utilities
    out there that will help), but it will help the performance of all your
    apps.
    >
    > Another weird thing is that some of our other webservers that access
    > the same backend don't have this issue - which implies it is
    > something specific to the one connection - however the connection
    > settings havent changed at all since the migration.
    >
    > Its all very annoying really!
    >
    > Any further thoughts?
    Not until you tell us what "not working" means. :-)
    I suspectu you are seeing the effects of the new version of MDAC that was
    installed along with your SQL Server.


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows 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