Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ODBC Oracle Table, Delete From Excel?

Greetings,
A work associate has created an ODBC Excel that populates from an Oracle
table.
We were wondering if it is possible, since the ODBC connection is already
there, to run VB code from Excel to delete a record from the table.

For example, if we encounter a row of data that needs deleted from the
table, and we want to use the cell containing the Part #, how do we tell
Excel to delete the record from the table using the part # as the qualifier?

Thank you for all your help.
Ron


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default ODBC Oracle Table, Delete From Excel?

If you have an ODBC connection you can use it to pass any SQL code recognized
by the ODBC driver. The standard SQL syntax for deleting a record is as
follows:
DELETE tablename.*
FROM tablename
WHERE criteria
I assume you know how to use ADO to set up the connection. Just set up a
string variable to hold the SQL command created as above, using the specific
part# in the criteria, then use the Connection.Execute method to pass the SQL
command to the database. Basic outline of code:

Dim Cn as ADODB.Connection, SQLCmd as String
Set Cn = New ADODB.Connection
Cn.Open(...) ' need to supply the connection string here, assume you have that
' ... Retrieve your records and find the one(s) you want to delete
SQLCmd = "DELETE MyTable.* FROM MyTable WHERE PartNo='" & PartNumber & "'"
'assuming an alphanumeric part number, so I put single quotes around it
Cn.Execute SQLCmd
....
--
- K Dales


"nowon" wrote:

Greetings,
A work associate has created an ODBC Excel that populates from an Oracle
table.
We were wondering if it is possible, since the ODBC connection is already
there, to run VB code from Excel to delete a record from the table.

For example, if we encounter a row of data that needs deleted from the
table, and we want to use the cell containing the Part #, how do we tell
Excel to delete the record from the table using the part # as the qualifier?

Thank you for all your help.
Ron



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default ODBC Oracle Table, Delete From Excel?

Thanks for the response,
I really don't know what the Cn.Open connection string is.
The excel file already makes the connection and already contains the
data from the table.
I open the file and it refreshes with data from the table.
do i still need to use the Cn.Open statement, or could the
Set Cn = Current ADODB.Connection? or something like that.

I only know that it is an oracle table and i have the table name:
REPORT1

Or since the connection is already established, can we just execure the
SQLCmd?

I'm sorry, but Oracle and Databases are all new to me

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect to Oracle using Microsoft ODBC for Oracle Kent Excel Programming 2 January 18th 06 03:53 AM
ODBC/VBA?EXCEL and ORACLE database BAC Excel Programming 7 July 14th 05 12:55 PM
Oracle odbc Slinjger Excel Discussion (Misc queries) 1 July 3rd 05 04:35 PM
Connect to Oracle Database through ODBC with VBA jamiee Excel Programming 1 April 15th 04 03:31 PM
Problems Using MS Oracle ODBC with Excel news.aristotle.net Excel Programming 3 April 2nd 04 04:41 PM


All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"