Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2006, 01:01 PM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default drop Oracle table from VBA excel

Hi

I am strugling to run an Oracle procedure that drops a table from within an excel VBA script. The script returns an invalid ODBC connection 'ODBC--connection to Database failed' error '3151'.

I am wandering if I can run this kind of procedures from VBA? Before I ran some procedures that delete or insert records but this is the first time I'm trying to drop a table.

the script I'm using is this

Function droptab()
Dim db As Database, LConnect As String, ws As Workspace, LSProc As QueryDef

LConnect = "ODBC;DRIVER={ORACLE ODBC DRIVER};DSN=???;UID=???;SERVER=???"

Set ws = DBEngine.Workspaces(0)

Set db = ws.OpenDatabase("", False, False, LConnect)

Set LSProc = db.CreateQueryDef("")
LSProc.Connect = LConnect

LSProc.Sql = "BEGIN droptabs; END;"
LSProc.ReturnsRecords = False
LSProc.ODBCTimeout = 0
LSProc.Execute
Set LSProc = Nothing
CallSProc = True

db.Close
Set db = Nothing

End Function

Any ideas?
Thanks
Pedro






Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Help Needed to write vba for Pivot Table in Excel sunny76 Excel VBA 1 June 28th, 2005 01:44 AM
(oracle 8i)Alter Table <table> coalesce partition combo Oracle 3 October 13th, 2004 09:35 AM
Writing to an Oracle table from Excel emad100 Excel VBA 0 October 29th, 2003 10:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.