Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error using ExecuteNonQuery function

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
Could use a little debugging help...

I'm trying to execute a function that updates a couple of fields in an Oracle database table. I know the SQL code is OK because I can execute it in a editor program and it works perfectly. I get an error back in my VB.NET app when I try to execute it. Here's the code:

Public Function GetNonQuery(ByVal sSQL As String, ByVal cnConn As OracleConnection) As Object

Try

Dim oResult As Object
Dim dcDataCmd As OracleCommand = New OracleCommand()
dcDataCmd.Connection = cnConn
dcDataCmd.CommandType = CommandType.Text
dcDataCmd.CommandText = sSQL

oResult = dcDataCmd.ExecuteNonQuery

Return oResult


Catch myErr As Exception

End Try

End Function


The code fails on the ExecuteNonQuery command, I'm not sure yet what the error code is (when I figure it out I'll post it). Can anyone tell me what is wrong here, why doesn't this work? It seems very straightforward...

Thanks

CraigHartz


CraigHartz
 
OK, I found out what the original problem was, turned out the connection was not yet open. I fixed that. Now there's a new problem -- the program goes off to never-never land when I execute the ExecuteNonQuery command.

BTW, the SQL statement (CommandText) is simply "UPDATE Table SET Month = '1', Year = '2006'"




CraigHartz
 
Never mind, I'm not sure what I changed but it is working now. Thanks anyway.


CraigHartz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top