| View previous topic :: View next topic |
| Author |
Message |
cogvos General User

Joined: 13 Aug 2007 Posts: 27
|
Posted: Mon Aug 20, 2007 9:10 am Post subject: Base. why can't the below find my table??? |
|
|
Dear all,
I have the following code which is executed when I press a button on a form
| Code: | Sub test
Dim thisform as Object
dim parentidfield as variant
dim parentname as variant
dim parentid as integer
REM SIMPLE CONNECTION which I copied from elsewhere
Dim Context ' the initial container for the connection
Dim DB ' the pointer to the database
Dim Conn ' the connection to the database
Dim Stmt ' a pointer for the sql statements
Dim Result ' what comes back
Dim strSQL As String ' a container for the sql
REM create database context
Context=CreateUnoService("com.sun.star.sdb.DatabaseContext")
REM get the database
DB=Context.getByName("Family Tree")
REM stablish connection to database
Conn=DB.getConnection("","")
REM create a statement service object
Stmt=Conn.createStatement()
thisform = ThisComponent.DrawPage.Forms.getbyname("person")
parentidfield= thisform.getbyname("Mother")
parentname=thisform.getbyname("mothername")
parentid=val (parentidfield.text)
strSQL= "SELECT * FROM PERSON1"
REM create an SQL command
REM finally, execute and store results in ResultSet Object
Result=Stmt.executeQuery(strSQL)
msgbox "hello world>>>" & parentid & "<<<"
End sub |
It fails at the line Result=Stmt.executeQuery(strSQL) stating that it cannot find my table (FAMILY1) and when I place a watch on conn and look at the table names FAMILY1 is not listed.
But
I have just created it! It is there in the tables list where you can select to work on tables, or forms or queries etc and I have just spent 10 minutes filling it with test data!
Thinking that this was some kind of weird commit problem I saved everything and quit Open Office. I can still add data to FAMILY1 but it still is not listed in the conn structure. What on Earth is going on???
Help, please, before I give up completely.
J. |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Mon Aug 20, 2007 9:56 am Post subject: |
|
|
probably a typo, but with | Code: | | strSQL= "SELECT * FROM PERSON1" | you do not read from table FAMILY1 but from PERSON1 ? |
|
| Back to top |
|
 |
cogvos General User

Joined: 13 Aug 2007 Posts: 27
|
Posted: Mon Aug 20, 2007 10:00 am Post subject: |
|
|
| ms777 wrote: | probably a typo, but with | Code: | | strSQL= "SELECT * FROM PERSON1" | you do not read from table FAMILY1 but from PERSON1 ? |
Rats caught up in mid rant. Yes it is a typo. Pls substitute person for family. The fact is though that it's not listed in the watch and it should be.
J |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Mon Aug 20, 2007 10:10 am Post subject: |
|
|
| can you post your database file somewhere to have others check it ? |
|
| Back to top |
|
 |
cogvos General User

Joined: 13 Aug 2007 Posts: 27
|
Posted: Mon Aug 20, 2007 12:50 pm Post subject: |
|
|
Sadly not, I could however email it, it's only 31K since I've sliced most of the test data out in desperation trying to find out what has caused this. I now have 8 tables, yet the count (conn.tables.count in the above) is only reading 6. So in effect I am missing two tables in the conn structure. I thought it might be something to do with relations, as not all the tables are related yet. But I only have 5 with relations so that's not it either.
It looks like something has glitched, in which case I will have to give up with open office base for now. However if someone is willing to post me a message, with their email I can forward the db for them to have a look at.
Many thanks
J.
<edit>
Just added another table, the count is still 6. |
|
| Back to top |
|
 |
cogvos General User

Joined: 13 Aug 2007 Posts: 27
|
Posted: Mon Aug 20, 2007 1:08 pm Post subject: |
|
|
A thought has just struck me. Is there any way of forcing Base to flush its caches? Just in case this fixes it?
J |
|
| Back to top |
|
 |
|