Ask Your Question
0

Problems connecting via macro to external (MariaDB) DB in Base [closed]

asked 2013-06-28 00:55:29 +0200

JAM gravatar image

updated 2015-11-03 01:41:21 +0200

Alex Kemp gravatar image

I would very much appreciate some help so I can continue to make progress on my project.

I'm working in Ubuntu 13.04. I've created a DB using MariaDB and successfully connect to it and can access and create tables in it using LibreOffice BaseEXCEPT I can't figure out how to modify a table using a macro.

When I search the web I keep coming up with the following code:

Dim Context Dim DB Dim Conn Dim Stmt Dim Result Dim strSQL As String Context=CreateUnoService("com.sun.star.sdb.DatabaseContext") DB=Context.getByName("MikesTest") Conn=DB.getConnection("","")

Stmt=Conn.createStatement() strSQL="INSERT INTO _ EMPLOYEES(FIRSTNAME,MIDDLENAME,LASTNAME,AGE,SSN) _ VALUES('Hubert','','Farnsworth','164','511-11-1111')" Stmt.executeUpdate(strSQL)

Conn.close()

My problem is, I haven't been able to get past DB=Context.getByName("MikesTest")

I keep getting the error message:

BASIC runtime error. An exception occurred Type: com.sun.star.container.NoSuchElementException Message: MikesTest.

"MikesTest" is the registered name of the DB in LO. That doesn't work. Nor does a full path to the DB. Nor does just the DB name without the full path.

So what is the trick here? I'm sure it is obvious to the initiated.

Thanks for any help on the frustrating stalemate.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-03 01:41:50.113670

2 Answers

Sort by » oldest newest most voted
1

answered 2013-06-30 21:22:23 +0200

JAM gravatar image

I think I found the problem. Although I thought the db was registered, it was not. I manually registered it and got past the error message which was stymying me.

edit flag offensive delete link more
1

answered 2013-06-30 21:23:28 +0200

JAM gravatar image

I got it! Unregistered DB. Manually registered and got past the immediate problem.

edit flag offensive delete link more

Comments

Thanks for reporting your solution.

oweng gravatar imageoweng ( 2013-07-01 14:24:58 +0200 )edit

I'm having a similar pb. Frst Form opens fine by macro :

Sub Ouvre_Recherche_par_nom( oEvent as variant ) ThisDatabaseDocument.FormDocuments.getByName("Recherche_par_nom").open End Sub

the secund gives ERROR : Type: com.sun.star.container.NoSuchElementException Message: Nouveau_Contact.

kirsch gravatar imagekirsch ( 2016-08-28 16:58:08 +0200 )edit

I'm having a similar pb :

opening a first Form "F_Contact." by macro work fine : Sub Ouvre_Recherche_par_nom( oEvent as variant ) ThisDatabaseDocument.FormDocuments.getByName("F_Contact").open End Sub

Opening a other form " New_Contact" with a new macro is not working : Sub Ouvre_New_Contact( oEvent as variant ) ThisDatabaseDocument.FormDocuments.getByName("New_Contact").open End Sub

ERROR Type: com.sun.star.container.NoSuchElementException Message: New_Contact !

kirsch gravatar imagekirsch ( 2016-08-28 17:11:01 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-28 00:55:29 +0200

Seen: 978 times

Last updated: Jun 30 '13