Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


In a database of mine a very convenient way to execute some operations is by
running a small series of SQL statements.

 

As Base has no direct way to run a text file of SQL statements I asked on
Ask Libre Office and was given code in Basic that would read and execute a
file of SQL.

 

The first few lines of code are shown below

 

REM  *****  BASIC  *****

rem Option Explicit

 

Sub DoSQL

 

rem how to read text file

rem https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=33009

rem how to execute sql 

rem
http://ask.libreoffice.org/en/question/21205/libreofficebase-how-to-execute-
sql-from-basic-script/

rem check database connection

DIM txtfile AS STRING

DIM f1 AS INTEGER

DIM s AS STRING

DIM oStatement AS OBJECT

 

MsgBox("Code started")

if IsNull(ThisComponent.CurrentController.ActiveConnection) then

     ThisComponent.CurrentController.connect

endif

 

If I run this from the macro menu it runs perfectly.

 

However if I create blank form with just one button and set the properties
of that button to

run the macro it fails at the line

 if IsNull(ThisComponent.CurrentController.ActiveConnection) then

 with the error message

 "BASIC runtime error.

Property or method not found: ActiveConnection."

 

Can anyone help me please?

 

My final objective would be a form with 3 or 4 buttons each of which would
execute a different file of SQL

 

Regards

 

Allan

 

__

Allan Newton

Optical System Design

 


-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.