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

Joined: 01 Jul 2007 Posts: 24
|
Posted: Sun Jul 01, 2007 12:16 pm Post subject: Making a connection to the database |
|
|
When I execute the following code to open my database connection;
| Code: | Sub testConnect
Dim DatabaseContext As Object
Dim DataSource As Object
Dim Connection As Object
Dim InteractionHandler As Object
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("job_db")
If Not DataSource.IsPasswordRequired Then
Connection = DataSource.GetConnection("","")
Else
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
Connection = DataSource.ConnectWithCompletion(InteractionHandler)
End If
End Sub |
Line that causes the error
| Code: |
DataSource = DatabaseContext.getByName("job_db")
|
When the line above is executed I get the following error:
I'm using a mysql database which I connect to and definately works with Base, but it is also username and password protected.
Thank you,
Andrew J. Leer |
|
| Back to top |
|
 |
leeand00 General User

Joined: 01 Jul 2007 Posts: 24
|
Posted: Mon Jul 02, 2007 9:05 am Post subject: Ah HA! |
|
|
| It has something to do with the fact that I moved the file from one directory to another....somewhere inside the .odb file there is an absolute path name. Is there any way to fix this? |
|
| Back to top |
|
 |
leeand00 General User

Joined: 01 Jul 2007 Posts: 24
|
Posted: Mon Jul 02, 2007 9:12 am Post subject: Okay somebody told me what to do... |
|
|
leeand00 asked:
| Quote: |
Hi, I just moved and .odb file from base to a diffrent directory and now when I try to run a macro which accesses a database it complains that it can't find the .odb file. Is there anyway to make the .odb file's path relative instead of absolute?
|
MechtiIDE Said:
| Quote: |
Register the new place under "Tools -> Options -> OpenOffice.org Base -> Databases"
|
And that fixed the problem. |
|
| Back to top |
|
 |
leeand00 General User

Joined: 01 Jul 2007 Posts: 24
|
Posted: Mon Jul 02, 2007 10:07 am Post subject: Just so people know what the error was: |
|
|
| Quote: |
BASIC runtime error.
An exception occured
Type: com.sun.star.lang.WrappedTargetException
Message:
file:///C:/.../previous absolute path to .odb file
|
|
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Fri Jul 06, 2007 1:18 pm Post subject: |
|
|
what happens if you provide a direct URL to the Base document rather than the registered datasource name? _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
|