Hi,

In my C# applicaiton, I use ADOX to reach and check the user permissions in
my Access database. To do this, there is a function named "GetPermissions".
This function gets 3 arguments where the 3rd one is optional. But the C#
compiler doesn't accept giving only 2 parameters and whatever I put into the
third one (null, "", etc.) I get an exception.

I want to ask whether anybody knows how to handle those optional parameters
in C#?

Thanks in advance...

Regards,

Özden

RE: Optional values? by Jestrade

Jestrade
Tue May 10 05:08:04 CDT 2005

I think that if this optional parameter is of type string, or object will
allow you put it to null.

Regards.
Josema.
"Ã?zden Irmak" wrote:

> Hi,
>
> In my C# applicaiton, I use ADOX to reach and check the user permissions in
> my Access database. To do this, there is a function named "GetPermissions".
> This function gets 3 arguments where the 3rd one is optional. But the C#
> compiler doesn't accept giving only 2 parameters and whatever I put into the
> third one (null, "", etc.) I get an exception.
>
> I want to ask whether anybody knows how to handle those optional parameters
> in C#?
>
> Thanks in advance...
>
> Regards,
>
> Ã?zden
>
>
>

Re: Optional values? by Michael

Michael
Tue May 10 05:36:45 CDT 2005

Özden Irmak wrote:

[...snip...]
> there is a function named "GetPermissions".
> This function gets 3 arguments where the 3rd one is optional. But the C#
> compiler doesn't accept giving only 2 parameters and whatever I put into
the
> third one (null, "", etc.) I get an exception.
>
> I want to ask whether anybody knows how to handle those optional
parameters
> in C#?
[...snip...]

AFAIK, C# does not support optional parameters. You can set each parameter
to null, as long as the parameter type supports it, but you'll need to check
in your method and act appropriate.

Can you tell us what exception you get and how your function looks like ?



Re: Optional values? by Carlos

Carlos
Tue May 10 05:45:12 CDT 2005

Try passing System.Type.Missing for missing optional parameters.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Özden Irmak" <ozdenirmak(at)isnet.net.tr> escribió en el mensaje
news:Op8HEqTVFHA.4028@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> In my C# applicaiton, I use ADOX to reach and check the user permissions
> in my Access database. To do this, there is a function named
> "GetPermissions". This function gets 3 arguments where the 3rd one is
> optional. But the C# compiler doesn't accept giving only 2 parameters and
> whatever I put into the third one (null, "", etc.) I get an exception.
>
> I want to ask whether anybody knows how to handle those optional
> parameters in C#?
>
> Thanks in advance...
>
> Regards,
>
> Özden
>



Re: Optional values? by Christof

Christof
Tue May 10 06:01:27 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_00A0_01C55560.6356A010
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi =D6zdem,

not sure, but i think this should work:

object =3D System.Reflection.Missing.Value;
myAdox.GetPersmission(param1, param2, missing);

Christof

"=D6zden Irmak" <ozdenirmak(at)isnet.net.tr> schrieb im Newsbeitrag =
news:Op8HEqTVFHA.4028@TK2MSFTNGP10.phx.gbl...
> Hi,
>=20
> In my C# applicaiton, I use ADOX to reach and check the user =
permissions in=20
> my Access database. To do this, there is a function named =
"GetPermissions".=20
> This function gets 3 arguments where the 3rd one is optional. But the =
C#=20
> compiler doesn't accept giving only 2 parameters and whatever I put =
into the=20
> third one (null, "", etc.) I get an exception.
>=20
> I want to ask whether anybody knows how to handle those optional =
parameters=20
> in C#?
>=20
> Thanks in advance...
>=20
> Regards,
>=20
> =D6zden=20
>=20
>
------=_NextPart_000_00A0_01C55560.6356A010
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2604" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>Hi =D6zdem,</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>not sure, but i think this should work:</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D3>object =3D =
System.Reflection.Missing.Value;</FONT></DIV>
<DIV><FONT size=3D3>myAdox.GetPersmission(param1, param2, =
missing);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D3><FONT face=3DArial =
size=3D2>Christof</FONT></FONT></DIV>
<DIV><FONT size=3D3><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV></FONT>
<DIV>"=D6zden Irmak" &lt;ozdenirmak(at)isnet.net.tr&gt; schrieb im =
Newsbeitrag <A=20
href=3D"news:Op8HEqTVFHA.4028@TK2MSFTNGP10.phx.gbl">news:Op8HEqTVFHA.4028=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>&gt;=20
Hi,<BR>&gt; <BR>&gt; In my C# applicaiton, I use ADOX to reach and check =
the=20
user permissions in <BR>&gt; my Access database. To do this, there is a =
function=20
named "GetPermissions". <BR>&gt; This function gets 3 arguments where =
the 3rd=20
one is optional. But the C# <BR>&gt; compiler doesn't accept giving only =
2=20
parameters and whatever I put into the <BR>&gt; third one (null, "", =
etc.) I get=20
an exception.<BR>&gt; <BR>&gt; I want to ask whether anybody knows how =
to handle=20
those optional parameters <BR>&gt; in C#?<BR>&gt; <BR>&gt; Thanks in=20
advance...<BR>&gt; <BR>&gt; Regards,<BR>&gt; <BR>&gt; =D6zden <BR>&gt;=20
<BR>&gt;</BODY></HTML>

------=_NextPart_000_00A0_01C55560.6356A010--


Re: Optional values? by Özden

Özden
Tue May 10 07:14:03 CDT 2005

Hi,

Thank you all first of all...

System.Reflection.Missing.Value still throws the same exception...



This is the function that I'm trying to use (Taken from ADO help) :




Gets the permissions for a group or user on an object.

Syntax

ReturnValue = GroupOrUser.GetPermissions(Name, ObjectType
[, ObjectTypeId])

Return Value

Returns a Long value specifying a bitmask containing the permissions that
the group or user has on the object.

Parameters

Name A String value specifying the name of the object for which to set
permissions.

ObjectType A Long value specifying the type of the object for which to get
permissions. The following constants are valid values for ObjectType:

Constant Description
adPermObjProviderSpecific Object is of a provider-defined type. An
error will occur if the ObjectType is adPermObjProviderSpecific and an
ObjectTypeId is not supplied.
adPermObjTable Object is a table.
adPermObjColumn Object is a column.
adPermObjDatabase Object is a database.
adPermObjProcedure Object is a procedure.
adPermObjView Object is a view.
adPermObjSchema Object is a schema.
adPermObjDomain Object is a domain.
adPermObjCollation Object is a collation.
adPermObjSchemaRowset Object is a schema rowset.
adPermObjCharacterSet Object is a character set.
adPermObjTranslation Object is a translation.


ObjectTypeId Optional. A Variant value specifying the GUID for a provider
object type not defined by the OLE DB specification. This parameter is
required if ObjectType is set to adPermObjProviderSpecific; otherwise, it is
not used.







The exception detail is this :

System.Runtime.InteropServices.COMException was unhandled


Regards,

Özden







"Özden Irmak" <ozdenirmak(at)isnet.net.tr> wrote in message
news:Op8HEqTVFHA.4028@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> In my C# applicaiton, I use ADOX to reach and check the user permissions
> in my Access database. To do this, there is a function named
> "GetPermissions". This function gets 3 arguments where the 3rd one is
> optional. But the C# compiler doesn't accept giving only 2 parameters and
> whatever I put into the third one (null, "", etc.) I get an exception.
>
> I want to ask whether anybody knows how to handle those optional
> parameters in C#?
>
> Thanks in advance...
>
> Regards,
>
> Özden
>



Re: Optional values? by Saurabh

Saurabh
Tue May 10 09:43:15 CDT 2005

Any more details as to what makes you think that the exception is being
thrown only because of the optional parameter rather than something else?

--Saurabh

"Özden Irmak" <ozdenirmak(at)isnet.net.tr> wrote in message
news:uf2rEnVVFHA.3240@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> Thank you all first of all...
>
> System.Reflection.Missing.Value still throws the same exception...
>
>
>
> This is the function that I'm trying to use (Taken from ADO help) :
>
>
>
>
> Gets the permissions for a group or user on an object.
>
> Syntax
>
> ReturnValue = GroupOrUser.GetPermissions(Name, ObjectType
> [, ObjectTypeId])
>
> Return Value
>
> Returns a Long value specifying a bitmask containing the permissions that
> the group or user has on the object.
>
> Parameters
>
> Name A String value specifying the name of the object for which to set
> permissions.
>
> ObjectType A Long value specifying the type of the object for which to
> get permissions. The following constants are valid values for ObjectType:
>
> Constant Description
> adPermObjProviderSpecific Object is of a provider-defined type. An
> error will occur if the ObjectType is adPermObjProviderSpecific and an
> ObjectTypeId is not supplied.
> adPermObjTable Object is a table.
> adPermObjColumn Object is a column.
> adPermObjDatabase Object is a database.
> adPermObjProcedure Object is a procedure.
> adPermObjView Object is a view.
> adPermObjSchema Object is a schema.
> adPermObjDomain Object is a domain.
> adPermObjCollation Object is a collation.
> adPermObjSchemaRowset Object is a schema rowset.
> adPermObjCharacterSet Object is a character set.
> adPermObjTranslation Object is a translation.
>
>
> ObjectTypeId Optional. A Variant value specifying the GUID for a
> provider object type not defined by the OLE DB specification. This
> parameter is required if ObjectType is set to adPermObjProviderSpecific;
> otherwise, it is not used.
>
>
>
>
>
>
>
> The exception detail is this :
>
> System.Runtime.InteropServices.COMException was unhandled
>
>
> Regards,
>
> Özden
>
>
>
>
>
>
>
> "Özden Irmak" <ozdenirmak(at)isnet.net.tr> wrote in message
> news:Op8HEqTVFHA.4028@TK2MSFTNGP10.phx.gbl...
>> Hi,
>>
>> In my C# applicaiton, I use ADOX to reach and check the user permissions
>> in my Access database. To do this, there is a function named
>> "GetPermissions". This function gets 3 arguments where the 3rd one is
>> optional. But the C# compiler doesn't accept giving only 2 parameters and
>> whatever I put into the third one (null, "", etc.) I get an exception.
>>
>> I want to ask whether anybody knows how to handle those optional
>> parameters in C#?
>>
>> Thanks in advance...
>>
>> Regards,
>>
>> Özden
>>
>
>



Re: Optional values? by Özden

Özden
Wed May 11 04:14:57 CDT 2005

Hi,

Ok, it is working now, there was another small problem in the code, where we
were trying to get permission of a column object...

Thank you all for taking time and trying to help me...

Regards,

Özden Irmak

"Özden Irmak" <ozdenirmak(at)isnet.net.tr> wrote in message
news:Op8HEqTVFHA.4028@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> In my C# applicaiton, I use ADOX to reach and check the user permissions
> in my Access database. To do this, there is a function named
> "GetPermissions". This function gets 3 arguments where the 3rd one is
> optional. But the C# compiler doesn't accept giving only 2 parameters and
> whatever I put into the third one (null, "", etc.) I get an exception.
>
> I want to ask whether anybody knows how to handle those optional
> parameters in C#?
>
> Thanks in advance...
>
> Regards,
>
> Özden
>