CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 1999
    Posts
    10

    Catalog.GetObjectOwner()

    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


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Catalog.GetObjectOwner()

    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.


  3. #3
    Join Date
    Aug 1999
    Posts
    10

    Re: Catalog.GetObjectOwner()

    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?


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Catalog.GetObjectOwner()

    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?


  5. #5
    Join Date
    Aug 1999
    Posts
    10

    Re: Catalog.GetObjectOwner()

    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..."




  6. #6
    Join Date
    Jul 1999
    Posts
    145

    Re: Catalog.GetObjectOwner()

    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.)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured