StoneCodeMonkey
Well-known member
- Joined
- Apr 17, 2009
- Messages
- 56
- Programming Experience
- 5-10
First things first, here is the code.
I am executing this code against a simple test database. I have a similar function that has the same signature, but returns a DataTable and it works fine. For the life of me I can not figure out why ExecuteNonQuery will not work. I have checked the database and the value is never updated. If I paste the sql into SQLDeveloper it executes just fine and the table is updated as expected.
Any ideas?
VB.NET:
Public Shared Function ExecuteNonQuery(ByVal ConnectionString As String, ByVal factory As DbProviderFactory, ByVal sql As String) As Integer
'When this function executes
'factory = {Oracle.DataAccess.Client.OracleClientFactory}
'sql = "update downtimearea set area = 'yyy' where downtimearea = '01'"
Dim rowsAffected As Integer = -1
'This works.
Using conn As DbConnection = factory.CreateConnection
conn.ConnectionString = ConnectionString
conn.Open()
If conn.State.Equals(ConnectionState.Open) Then
Try
'This works
Dim command As DbCommand = conn.CreateCommand
command.CommandText = sql
command.CommandType = CommandType.Text
'**********This blocks and never returns.
rowsAffected = command.ExecuteNonQuery()
Catch ex As Exception
'**********No exception is ever thrown.
Debug.Print(ex.Message)
End Try
End If
End Using
Return rowsAffected
End Function
I am executing this code against a simple test database. I have a similar function that has the same signature, but returns a DataTable and it works fine. For the life of me I can not figure out why ExecuteNonQuery will not work. I have checked the database and the value is never updated. If I paste the sql into SQLDeveloper it executes just fine and the table is updated as expected.
Any ideas?
Last edited: