Discussion:
ADODB.Stream Open() in c#
(too old to reply)
David Sandor
2003-07-31 01:36:13 UTC
Permalink
Question:
This is what I want to do...
ADODB.Stream Stream = new ADODB.StreamClass();
Stream.Open();

There are 5 arguments for a Stream.Open() however they are all optional. You can not pass nulls to the arguments as it will not compile. Someone posted a solution some time ago that indicated to pass Type.Missing, however it will not compile because of a 'cannot convert from .. to.. ' error. Any solutions?

Object Browser Definition of ADODB.Stream.Open()
public abstract new void Open ( System.Object Source , ADODB.ConnectModeEnum Mode , ADODB.StreamOpenOptionsEnum Options , System.String UserName , System.String Password )

Tried:

Stream.Open(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

compiler Errors:

Argument '2': cannot convert from 'object' to 'ADODB.ConnectModeEnum'
Argument '3': cannot convert from 'object' to 'ADODB.StreamOpenOptionsEnum'
Argument '4': cannot convert from 'object' to 'string'
Argument '5': cannot convert from 'object' to 'string'


Thanks,

David S.
Mattias Sjögren
2003-07-31 08:54:48 UTC
Permalink
David,
Post by David Sandor
Someone posted a solution some time ago that indicated to pass Type.Missing, however it will not compile because of a 'cannot convert from .. to.. ' error. Any solutions?
You can only use Type.Missing for optional object/VARIANT parameters.
For strongly typed parameters you have to look up the default value
and pass in that explicitly.

http://www.dotnetinterop.com/faq/?q=MissingOptional

In this case I think you'll end up with

Stream.Open( (ConnectModeEnum)0, (StreamOpenOptionsEnum)0xffffffff,
"", "" );



Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
John
2009-09-22 19:00:26 UTC
Permalink
Can you provide more details on how you solved this, or a code example

From http://www.developmentnow.com/g/21_2003_7_0_0_103532/ADODB-Stream-Open-in-c.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Continue reading on narkive:
Loading...