Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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.

click to hide/show revision 2
retagged

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

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.

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

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.