473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Enterprise libraries

Im not sure if this is the correct group for this question - please feel free
to redirect me to a more appropriate group if necessary

Im assessing Enterprise Libraries and I wanted to know how objects are
disposed of

ie writing data access code by hand i might write soemthing like this

Dim strConnTxt As String =
"Server=(local);Database=Northwind;Integrated Security=True;"
Dim strSql As String = "select * from products where categoryid = "
& txtCategoryID.Text

'create and open the connection object
Using objConn As New SqlConnection(strConnTxt)
'Using Definition
'http://msdn.microsoft.com/en-us/library/htd05whh.aspx
objConn.Open()

'Create the command object
Using objCmd As New SqlCommand(strSql, objConn)
objCmd.CommandType = CommandType.Text

'databind the datagrid by calling the ExecuteReader() method
GridView1.DataSource = objCmd.ExecuteReader()
GridView1.DataBind()
lblCount.Text = ""

End Using

'close the connection
objConn.Close()
End Using

As I understand, by using the 'Using' block, the connection & command
objects are disposed of when exiting the block

If however I use the following code using DataAccessApplicationBlock, how
are these objects (that are inevitably created within the application block
code) disposed of?

Dim db As Database = DatabaseFactory.CreateDatabase()
Dim dbCommand As DbCommand =
db.GetStoredProcCommand("GetProductsByCategory")

db.AddInParameter(dbCommand, "CategoryID", DbType.Int32,
txtCategoryID.Text)
db.AddOutParameter(dbCommand, "RecordCount", DbType.Int32,
txtCategoryID.Text)

GridView1.DataSource = db.ExecuteReader(dbCommand)
GridView1.DataBind()

Jul 24 '08 #1
0 851

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

Similar topics

2
by: Russell E. Owen | last post by:
I'm trying to build Python 2.3.4 from source on a RedHat Enterprise machine for installation in a net-wide accessible directory /net/python. I tried all of the following variants of ./configure...
53
by: john67 | last post by:
The company I work for is about to embark on developing a commercial application that will cost us tens-of-millions to develop. When all is said and done it will have thousands of business...
3
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
0
by: Adam J. Schaff | last post by:
Hello all. I am part of a team about to start work on a large enterprise application. There will be a main application and a bunch of smaller applications that are all related and use the same...
7
by: Joe | last post by:
Hello All: I am trying to use the Enterprise Libraries created by Microsoft to update a DB2 database and am stuck. I need to be able to Insert, Update and Delete records from the DB2 datbase...
0
by: John | last post by:
Hi, I was wondering if it is possible to get the enterprise library (EL) 3.x to read/write the settings.settings section of the .config file? Because when you use the settings.settings in an...
0
by: Erick | last post by:
I'm trying to create a single DLL which all developers in our organisation will reference. I want to place inside it the Microsoft Enterprise Libraries. And expose them out through the DLL. On...
0
by: Alex | last post by:
Hi, We're developing a large winform application using VB 2005, and we'd like to use the MS Enterprise Libraries to handle logging, audits, error handling, validation, caching, and more. I've...
62
by: estherschindler | last post by:
This is part of a series examining the strengths and weaknesses of various scripting languages, with particular attention to enterprise (read: big company) use. You Used Python to Write WHAT?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.