473,804 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ExecuteNonQuery Query

This is a two part question.

(1) After opening a connection and calling ExecuteNonQuery within a
transaction in .NET 2.0, is any resource cleanup still required in a finally
block?

(2) My code calls the OpenRowset Bulk provider using a command query string,
but it seemed ExecuteNonQuery was the proper method to call because nothing
is returned. Is this correct?

--
Regards,

Fred Chateau
fchateauAtComca stDotNet
Aug 31 '06 #1
2 1552
Fred Chateau wrote:
(1) After opening a connection and calling ExecuteNonQuery within a
transaction in .NET 2.0, is any resource cleanup still required in a finally
block?
You still need to close the connection.

Arne
Sep 1 '06 #2
1) Close your connection again and dispose your command object
2) Not sure about that exact SQL, but ExecuteNonQuery is best when you
don't need a result set. It does return the number of rows affected
however, which you can choose not to assign if you so wish.
Fred Chateau wrote:
This is a two part question.

(1) After opening a connection and calling ExecuteNonQuery within a
transaction in .NET 2.0, is any resource cleanup still required in a finally
block?

(2) My code calls the OpenRowset Bulk provider using a command query string,
but it seemed ExecuteNonQuery was the proper method to call because nothing
is returned. Is this correct?

--
Regards,

Fred Chateau
fchateauAtComca stDotNet
Sep 1 '06 #3

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

Similar topics

2
7348
by: Mark | last post by:
Hi, I have a sqlCommand object that I use to execute an SQL statement. I thought I could use the ExecuteNonQuery to test for the number of rows returned by the sql command but it does not seem to work My code is below.. Dim sSQL As String = "SELECT Blah FROM Table WHERE BlahID = 5" Dim oCOmmand As New SqlClient.SqlCommand(sSQL, openDatabase)
0
3078
by: johnnymack0730 | last post by:
Hello - I am currently working on an asp.net application that needs to be able to update an access table using ExecuteNonQuery method. I have all the code setup, it runs, there are no errors thrown, yet...nothing is being updated. The only thing I can see is the ExecuteNonQuery returns 0 when the update is run. Can anyone help please? Here is some of the code:
4
6507
by: MDW | last post by:
Hey all. I'm confused. I'm trying to add a single record into an Access 2000 database using ASP.Net. Here is the code: objConn = New OleDbConnection(strConnect) objConn.Open objCommand = New OleDbCommand("INSERT INTO LOGIN_MASTER (LOGIN_ID, PWD, F_NAME, L_NAME, TYPE_ID) VALUES ('" & strEmail & "','" & strPwd & "','" &
1
8586
by: DaveS | last post by:
Hi! I originally posted this in the dotnet.framework.adonet, but I'm not sure that was the right place. Anyway... I am exeuting an INSERT query from within a public function. Is there any way to know if the entire INSERT query completed updating in the database? It appears that code continues to execute even before the query has
22
4332
by: b_r | last post by:
Hi, I'm trying to make a simple operation (insert into DB) in VB 2005 and SQL Server. The code is as follows: Dim sConnectionString As String = _ "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DB.mdf....
5
1527
by: Matt | last post by:
Hi all, I'm trying to use the following code in an application: // retrieve the connection string string strDbcx = Globals.strDbcx; // create the connection OleDbConnection dbcx = new OleDbConnection(strDbcx); // open the connection dbcx.Open();
0
3867
by: nostradumbass77 | last post by:
Using Enterprise Library 2.0 (Jan 06) and .NET 2.0 (VB.Net 2005) Dim dbPF As Data.Common.DbProviderFactory Try dbPF = Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb") db = New Microsoft.Practices.EnterpriseLibrary.Data.GenericDatabase( _ "Provider=Microsoft.Jet.OLEDB.4.0;Data
8
4588
by: Tony M | last post by:
Shouldn't the ExecuteNonQuery be TRUE if it finds a record and FALSE is not? I get FALSE all the time and I seeded the database with the email address. I just want to check if record exist before moving on. If this doesn't work I guess I could load a datatable and check to see if rows 0. Dim cnString As OleDbConnection cnString = New OleDbConnection("Provider=MicroSoft.Jet.OLEDB.4.0; Data
2
3744
by: fniles | last post by:
I am using VB.NET 2005 and MS Access. I use OLEDbCommand ExecuteNonQuery to delete a record from a database. Whenever the program gets a message, it creates a new thread to process that message. In the thread I open the database, then process the message. Sometimes I get an error "Error Cannot open action query ''". Why can it execute the query and how to fix it ? Thank you. Public Class Best
0
9707
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
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
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...
0
10082
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
6856
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
5525
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...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
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.