cmd.ExecuteNonQuery() completing?

  • Thread starter Thread starter DaveS
  • Start date Start date
D

DaveS

Hi!

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 ADO.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
 
I would handle this inside your query. or sproc if you are using sprocs.
Check for a return value or the number of rows affected.
 
Back
Top