473,666 Members | 2,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SET NOCOUNT ON; Multiple Recordsets; ADO Command Text

MS-SQL 2000, Access 2003, ADO 2.8

Please, consider the SQL string in the following code:

Dim r As ADODB.Recordset
Dim r2 As ADODB.Recordset
Set r = CurrentProject. Connection.Exec ute( _
"SET NOCOUNT ON " _
& "SELECT * FROM FFDBATransactio ns" _
& "; SET NOCOUNT ON " _
& "SELECT * FROM [4060148Transact ions]")
Set r2 = r.NextRecordset
Debug.Print r.GetString(adC lipString, 1, vbTab, vbNewLine)
Debug.Print r2.GetString(ad ClipString, 1, vbTab, vbNewLine)
Set r = Nothing

that is:
"SET NOCOUNT ON " _
& "SELECT * FROM FFDBATransactio ns" _
& "; SET NOCOUNT ON " _
& "SELECT * FROM [4060148Transact ions]"

As I understand NOCOUNT, if we used this in a stored procedure the
first SET NOCOUNT ON would be valid for the whole stored procedure and
the second SET NOCOUNT ON would be redundant.

But what about using command text?
They are both useful?
Neither is useful?
The first is, but the second isn't?

Dec 9 '05 #1
1 11838

In both cases the first SET NOCOUNT ON is all that is required.

You should really have a SET NOCOUNT OFF at the end as well in order to
reset to the default behaviour.

It is still useful to have the SET NOCOUNT ON to prevent the generation of
the row count that sql reports, especially in a multiple recordset situation
as this row count is interpreted by ADO as another recordset.
--
Terry Kreft

"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com...
MS-SQL 2000, Access 2003, ADO 2.8

Please, consider the SQL string in the following code:

Dim r As ADODB.Recordset
Dim r2 As ADODB.Recordset
Set r = CurrentProject. Connection.Exec ute( _
"SET NOCOUNT ON " _
& "SELECT * FROM FFDBATransactio ns" _
& "; SET NOCOUNT ON " _
& "SELECT * FROM [4060148Transact ions]")
Set r2 = r.NextRecordset
Debug.Print r.GetString(adC lipString, 1, vbTab, vbNewLine)
Debug.Print r2.GetString(ad ClipString, 1, vbTab, vbNewLine)
Set r = Nothing

that is:
"SET NOCOUNT ON " _
& "SELECT * FROM FFDBATransactio ns" _
& "; SET NOCOUNT ON " _
& "SELECT * FROM [4060148Transact ions]"

As I understand NOCOUNT, if we used this in a stored procedure the
first SET NOCOUNT ON would be valid for the whole stored procedure and
the second SET NOCOUNT ON would be redundant.

But what about using command text?
They are both useful?
Neither is useful?
The first is, but the second isn't?

Dec 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
16526
by: (Pete Cresswell) | last post by:
I posted this in the MS Access group, but no luck. ------------------------------------------ I've got another stored procedure in the same app that returns multiple recordsets and the code works. But now I've written another SP and the code traps out with the 3251 message. The SP is writing two recordsets. When I run the SP in Query Analyzer, both recordsets appear.
4
1774
by: James | last post by:
Quick question about closing recordsets and connection objects. We're in the process of rewriting a TON of bad code. None of it is even remotely tabbed properly, it's impossible to read half the time and it never closes connection objects or recordsets. Unfortunately, I've been assigned the task of closing them. I assume I'm just doing: recordset.close Set recordset = Nothing conn.close
22
6092
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to a combo or listbox. It all works nicely and allows me to do things such as sorting by clicking on column headings. Recently, all the machines here were upgraded to Access XP from 97 and I thought it might be time to take advantage of the new...
7
2535
by: Leon | last post by:
DOES SETTING NOCOUNT ON option affect my stored procedures and website performance in anyway within my asp.net application? When and when not to set SET NOCOUNT ON? I know what it does but not exactly where and when I want to use it. i.e. CREATE PROCEDURE GetAuthorization 2.0 @Username Varchar( 20 ),
6
4986
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
16
5718
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and got a nudge in the right direction from Mr. Kreft. I promised to provide details once working, so here it is. The code is shown below. My next step is to build this technique into my application. I'm hoping for substantial performance gain. ...
6
6824
by: blue875 | last post by:
Hello helper people who are smarter than me: I have a form that needs to submit multiple queries to different tables during one Sub's execution. Some sections are as simple as: 1| With rst 2| .Open query1 3| .Close 4| .Open query2 5| End With
4
1508
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I have a textbox for searching, a listbox to display the searched results, and a big textbox (memo) to display the clicked-results of the listbox item. My question is: should I load the controls with objects, and therefore store everything in...
0
2358
by: nachiket2k2 | last post by:
Hi, I am using VB 6.0, ADO 2.0 with MS Access 2000 Database. in a vb form, i need to fatch data from 3 different tables (ABC.MDB). it will be a tedious job if i create 3 connections with 3 recordsets. is it possible to do programming in such a way that we can use multiple recordsets with SAME connection? firing SQL statments one after the other and building recordsets. each recordset will contain different no. of records. if yes,...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.