473,946 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

commandbehavior .closeconnectio n with applicationbloc ks

I am calling a shared fucntion within a class from codebehind with asp.net. The class returns a sqldatareader to be bound to a datalist. I am also utilizing ms applicationbloc ks. How can I return the datareader from the shared function so that the datareader is closed properly after it has been bound

th
dave
Nov 18 '05 #1
5 2696
Hi Dave,

Normally we can call the CLose method of the SQLDataReader, for example:

Dim myreader As SQLDataReader

Dim o As New MyDataClass

myreader = o.GetReader

DataList1.DataS ource = myreader

DataList1.DataM ember = "Name"

DataList1.DataB ind()

myreader.Close( )

By the way, we don't need to close the connection since it will be managed
by connection pool.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
Hi Dave,

Does my suggestion answer your question? Or you have other concern?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Your post did not answer my question

1.) I am using MS Data Application blocks to return the datareader through dr = sqlhelper.getda treader(...)
The problem occurs because i am running this within a function and returning to the calling program the datareader. There is a property commandbehavior .closeconnectio n that will close the data reader after all elements have been read. How can i use commandbehavior .closeconnectio n if I use MS Data Application blocks

2) Your example does not align with the description of the problem. Remember that the call to the datareader is within a function and the reader is returned from the function. If i used your example and returned the reader it would not work as the reader would have been closed
th
dave
Nov 18 '05 #4
Hi Dave,

If My understanding is correct, is it "executeRea der" in Data Application
blocks.

To make "ExecuteRea der" work with commandbehavior .closeconnectio n, we need
to pass in a external Connection. Following are source code of it:

Private Overloads Shared Function ExecuteReader(B yVal connection As
SqlConnection, _
ByVal transaction
As SqlTransaction, _
ByVal commandType
As CommandType, _
ByVal commandText
As String, _
ByVal
commandParamete rs() As SqlParameter, _
ByVal
connectionOwner ship As SqlConnectionOw nership) As SqlDataReader
'create a command and prepare it for execution
Dim cmd As New SqlCommand()
'create a reader
Dim dr As SqlDataReader

PrepareCommand( cmd, connection, transaction, commandType,
commandText, commandParamete rs)

' call ExecuteReader with the appropriate CommandBehavior
If connectionOwner ship = SqlConnectionOw nership.Externa l Then
dr = cmd.ExecuteRead er()
Else
dr = cmd.ExecuteRead er(CommandBehav ior.CloseConnec tion)
End If

'detach the SqlParameters from the command object, so they can
be used again
cmd.Parameters. Clear()

Return dr
End Function 'ExecuteReader

As you see when last parameter is SqlConnectionOw nership.Externa l,
CommandBehavior .CloseConnectio n will be used. Is this helpful in your
project?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5
Hi Dave,

How about my suggestion? Is it helpful or you have other concerns?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6

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

Similar topics

0
327
by: Karuppasamy | last post by:
Hi i am using Microsoft.ApplicationBlocks.Logging building block to publish the events to the Event Log and Sql Server using the Log and Sql sinks. By default, the log message contains the key-value pairs like AppDomainName, MachineName, ApplicationName, EventId, Message, etc. I would like add some attributes to that. How do i add some more attributes for example UserName, ModuleName, etc to the published message ? I have tried to add...
0
1499
by: Basem | last post by:
I have found people with similar errors using the ConfigurationManagement application block, but those solutions don't seem to do anything...basically, just trying to read in a configuration xml file using this application block, and getting the same error over and over no matter what. Here is my setup: app.config file: ----------------
0
1155
by: Mark | last post by:
I have a data access component that returns a SqlDataReader object. public SqlDataReader GetFeaturedArtists() { SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings) using(SqlCommand cmd = new SqlCommand( "SELECT artistName, ar.artistId "+ "FROM featuredArtist fa "+ "JOIN artist ar ON fa.artistId=ar.artistId"
1
7499
by: bootman | last post by:
Greetings, Can someone please help me with the following? I am trying to compile a C# object which contains a reference to the Microsoft.ApplicationBlocks.Data library. I have compiled the csproj file into a dll and it has been copied to my applications' /bin folder, I then create a test.aspx file and imported the library, the page loads fine, hence I assume it test.aspx page can find the package.
5
363
by: dave | last post by:
I am calling a shared fucntion within a class from codebehind with asp.net. The class returns a sqldatareader to be bound to a datalist. I am also utilizing ms applicationblocks. How can I return the datareader from the shared function so that the datareader is closed properly after it has been bound th dave
1
4400
by: Oney | last post by:
I use Microsoft Exception management block to publish exception to event log. but some error occured. Error is blow, how can I solve this problem ??? Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
1
2679
by: Abc | last post by:
Namespace or type 'Data' for the Imports 'Microsoft.ApplicationBlocks.Data' cannot be found. is the error which i am getting while importing Microsoft.ApplicationBlocks.Data namespace. Can please any one tell me why Thanks,
2
4072
by: drew.ferraro | last post by:
Hi, I am trying to build a .DLL file that uses "'Microsoft.ApplicationBlocks.ExceptionManagement.Interfaces'". I am trying to build this .DLL as fully signed. However, when I try to build, I get the following error: "Unable to emit assembly: Referenced assembly 'Microsoft.ApplicationBlocks.ExceptionManagement.Interfaces' does not have a strong name"
0
2324
by: mateipuiu | last post by:
When a try to run a client build on 2005, which uses the Microsoft.ApplicationBlocks.Cache.dll reference, when using a Microsoft.ApplicationBlocks.Cache.dll created on Debug mode, the client works just fine, but when a use a Microsoft.ApplicationBlocks.Cache.dll created on Release mode, the client doesn't work no more, and I get this error message: ********************************************* 1) Exception Information...
1
1417
by: linda.chen | last post by:
Hi all, I am working on a project which is created a couple years ago. It is written in C# (.net 1.1) and the developer has left the project. The auto-update feature is current not working. When I run the startup I keep getting this error message: "An unhandled exception of type 'System.TypeLoadException' occurred in microsoft.practices.enterpriselibrary.configuration.dll
0
10149
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
9974
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
11140
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
11320
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
10679
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...
1
8240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6317
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4928
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3524
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.