Click to See Complete Forum and Search --> : Catalog.GetObjectOwner()


PedroD
November 3rd, 1999, 04:07 AM
Hi all.
I'm currently writing an application framework for use with Access 2000, and in that respect, I need to (in code) to get the owner of the current database file.
¨
According to all manuals, the proper way to do this, is to use the method "getObjectOwner()", with NULL as the object name, and adPermObjDatabase
as the object type:


''/
'' This function displays a messagebox indicating who is the owner
'' of the current project.
'' @author PGD, Oct 99
'/
public Sub DisplayOwner()
Dim myCatalog as new ADOX.Catalog
Dim myString as string

myString = ""

With myCatalog
.ActiveConnection = currentproject.Connection
myString = .GetObjectOwner(null, adPermObjDatabase)
End With

msgbox "The owner of this database file is " & myString, vbOkOnly
End Sub




I keep getting "invalid use of Null" when I try to do this. The manuals
state that it should work. My version of ADO is 2.1

Any help given would be greatly appreciated!

Pedro G. Dias
Oslo, Norway

Lothar Haensler
November 3rd, 1999, 04:23 AM
IMHO this is a syntax error.
The first argument to getObjectOwner is of type String. You cannot pass NULL in this case. Use an empty string ("") instead.

PedroD
November 3rd, 1999, 04:27 AM
Hi and thank you for the reply.
I've tried passing all known forms of null (0, "", '', etc) but none of them work. Any other suggestions?

Lothar Haensler
November 3rd, 1999, 04:31 AM
well, the "" wouldn't cause a compile-time error.

Still, in MSDN I found 2 different descriptions for GetobjectOwner. One says, that the first parameter is of type Variant (which would allow you to specify NULL), the other says, the first parameter is of type string.
The first version is from the Office2000 SDK.
may be you can get that version of the ADOX.DLL?

PedroD
November 3rd, 1999, 04:58 AM
I've tried both using a variant data type, and setting that to both NULL and "" without any success.. I still can't seem to get the function to work..

When using emptystring (""), I get the message "The application is using arguments that are of the wrong type..."

Mikesc
November 3rd, 1999, 09:43 AM
I tried out a simplified version of your code, set a connection object to the sample DB for Access2000 and called the function with the constant you provided and vbNullString. It gave me the same error you mentioned. BUT I when I switched to vbNullChar it gave me an error message that said "This object has no owner." I have no idea what the owner of a DB might be but from the error message I got, it seems that the function is working correctly with vbNullChar. ( I used ado2.1 and OLEDB for Jet 4.0 in my connection string.)