473,382 Members | 1,425 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,382 software developers and data experts.

cmd.ExecuteNonQuery() completing?

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
finished. However, when I check cmd.State.ToString, it
says "Open", which gives me no info on the status of the
query.

Is there a more robust way to execute an Update query in
the VB.NET world?

myGlobals.connBE is an open connection to an Access
database.
Public Function ActionQuery(ByVal strActionSQL As String)
As String
Dim cmd As OleDbCommand = New OleDbCommand
With cmd
.Connection = myGlobals.connBE
.CommandType = CommandType.Text
.CommandText = strActionSQL
Try
.ExecuteNonQuery()
Return String.Empty
Catch ex As Exception
ErrorHandler(...)
Return ex.ToString
End Try
End With
End Function
TIA,

Dave
Nov 20 '05 #1
1 8530
cmd.ExecuteNonQuery returns the number of rows affected by the command. Have
you checked the return value?
"DaveS" <st***********@acm.org> wrote in message
news:02****************************@phx.gbl...
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
finished. However, when I check cmd.State.ToString, it
says "Open", which gives me no info on the status of the
query.

Is there a more robust way to execute an Update query in
the VB.NET world?

myGlobals.connBE is an open connection to an Access
database.
Public Function ActionQuery(ByVal strActionSQL As String)
As String
Dim cmd As OleDbCommand = New OleDbCommand
With cmd
.Connection = myGlobals.connBE
.CommandType = CommandType.Text
.CommandText = strActionSQL
Try
.ExecuteNonQuery()
Return String.Empty
Catch ex As Exception
ErrorHandler(...)
Return ex.ToString
End Try
End With
End Function
TIA,

Dave

Nov 20 '05 #2

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

Similar topics

10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
2
by: jdb | last post by:
Hi, I am adding a record to the database using an ExecuteNonQuery, which adds without problem. Now after the record is added I run a method passing in some info as well as the curretnly opened...
3
by: keithb | last post by:
What can I put in a stored procedure to control what gets returned by command.ExecuteNonQuery()? I already tried this: param = comm.CreateParameter(); param.ParameterName = "@Success"; ...
2
by: sudhashekhar30 | last post by:
hi all i have textbox in step in wizard control(step-10). there are 10 steps. so i want validation on every page and user can't move to other step without completing all correct entry. when i...
1
by: sarabrk | last post by:
Hi, I am having a problem when running a windows application. I see the "The thread 0x328 has exited with code 0 (0x0)." message in the output and the forms still open even after completing the...
2
by: TheSteph | last post by:
Hi I have a SQLCommand that do updates on a table. I have a loop where I set the parameters then I call ExecuteNonQuery. For . { . Set the SQLCommand's Params Values;
1
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... There are a few questions wrapped up in this, but the main one is that the WebService.MyMethodAsync() methods that are automatically generated in the client code by VS 2005 don't seem to...
1
by: Ivan Ven Osdel | last post by:
Not really, I have just worked with them more. ----- Original Message ----- From: "Ali Servet Dönmez" <asd@pittle.org> To: python-list@python.org Sent: Wednesday, July 2, 2008 1:15:04 PM GMT...
4
by: raghavv | last post by:
Hi, How do you implement auto completing with jcombobox. thank you.
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.