ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programs hangs when deleting elements with ADO DB and Oracle (https://www.excelbanter.com/excel-programming/394012-programs-hangs-when-deleting-elements-ado-db-oracle.html)

[email protected]

Programs hangs when deleting elements with ADO DB and Oracle
 
Hello!

I have a problem concerning ADO DB 2.8 and Oracle 10g. I wrote a small
VBA (v6.0) program to use Excel 2003 SP2 as a front-end to the
database.

I did not encounter problems trying to query the database or update or
insert data by using SQL statements. However, I can't manage to delete
data from the database. Excel hangs when I try to execute the
statement.

The essential part of the code looks as follows:
------------code--------------------
Private connection As ADODB.connection

Public Function GetConnection() As ADODB.connection
If connection Is Nothing Then
Set connection = New ADODB.connection
connection.Open (CONNECTION_STRING)
End If

Set GetConnection = connection
End Function

Public Sub TestDelete()
GetConnection.Execute ("DELETE FROM TEST_SCHEMA.TEST_TABLE")
End Sub
------------code--------------------

I can execute the SQL statement without any problems using TOAD for
Oracle with the same connection parameters I used for this example (in
the connection string which is a const in my code snippet). I have
tried to use the OLE DB provider and the ODBC driver Microsoft offers,
but the result was the same: my VBA program and Excel freeze, and I
have no idea what to do.

I would appreciate any help. This is a crucial part for my program,
and I have already spent much time trying to find a solution for this
problem.

TIA && kind regards,
Gernot


Les

Programs hangs when deleting elements with ADO DB and Oracle
 
I believe that you need to add an ADODB command object. My ADO is a little
rusty, but try:

Dim myConnection As ADODB.Connection
Dim myCommand As ADODB.Command
Dim mySql As String

Set myConnection = New ADODB.connection
myConnection.Open (CONNECTION_STRING)

mySql = "DELETE FROM TEST_SCHEMA.TEST_TABLE"

Set myCommand = New ADODB.Command
myCommand.ActiveConnection = myConnection
myCommand.CommandType = adCmdText
myCommand.CommandText = mySql
myCommand.Execute

--
Les Torchia-Wells


" wrote:

Hello!

I have a problem concerning ADO DB 2.8 and Oracle 10g. I wrote a small
VBA (v6.0) program to use Excel 2003 SP2 as a front-end to the
database.

I did not encounter problems trying to query the database or update or
insert data by using SQL statements. However, I can't manage to delete
data from the database. Excel hangs when I try to execute the
statement.

The essential part of the code looks as follows:
------------code--------------------
Private connection As ADODB.connection

Public Function GetConnection() As ADODB.connection
If connection Is Nothing Then
Set connection = New ADODB.connection
connection.Open (CONNECTION_STRING)
End If

Set GetConnection = connection
End Function

Public Sub TestDelete()
GetConnection.Execute ("DELETE FROM TEST_SCHEMA.TEST_TABLE")
End Sub
------------code--------------------

I can execute the SQL statement without any problems using TOAD for
Oracle with the same connection parameters I used for this example (in
the connection string which is a const in my code snippet). I have
tried to use the OLE DB provider and the ODBC driver Microsoft offers,
but the result was the same: my VBA program and Excel freeze, and I
have no idea what to do.

I would appreciate any help. This is a crucial part for my program,
and I have already spent much time trying to find a solution for this
problem.

TIA && kind regards,
Gernot



[email protected]

Programs hangs when deleting elements with ADO DB and Oracle
 
Hello!

On Jul 24, 4:26 pm, Les wrote:
I believe that you need to add an ADODB command object. My ADO is a little
rusty, but try:


[snip Code]

No, that was not the problem. I locked the table by looking at it with
TOAD, which I unfortunately didn't realise until someone told me.
Thank you anyway for your help, I appreciate it very much.

Kind Regards,
Gernot



All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com