Hi Cor:
I'm talking about having to do this:
private string CreateOledbConnectionString ()
{
try
{
Interop.Db.IDataSourceLocator mydlg = (Interop.Db.IDataSourceLocator)new
Interop.Db.DataLinksClass ();
mydlg.hWnd = (int)this.Handle;
Interop.Db._Connection ADOcon = (Interop.Db._Connection)new
Interop.Db.ConnectionClass();
Hashtable ht = LtnDDBB.ParseConnectionString ( tCString.Text );
ADOcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist
Security Info=False";
object ADOconAux = ADOcon;
return = _ConnectionString =
( mydlg.PromptEdit( ref ADOconAux ) ) ?
ADOcon.ConnectionString : ""; //All OK
}
catch
{
//Error. Probably MSDASC is not available
}
//If MSDASC is not available, show my own dialog
return CreateConnection ( new Db.OledbCSBuilder () );
}
Using this: (The rason to not use simple iterop (using references) is that
I'm developing a class library (.dll) and using interop makes me carry with
more .dlls as Interop.ADOX.dll).
namespace Interop.Db
{
[Guid("2206CDB2-19C1-11D1-89E0-00C04FD7A829")]
[ComImport]
[TypeLibType((short)2)]
[ClassInterface(ClassInterfaceType.None)]
internal class DataLinksClass // : IDBPromptInitialize, IDataInitialize,
IDataSourceLocator, DataLinks
{
}
[Guid("00000514-0000-0010-8000-00AA006D2EA4")]
[ComImport]
[TypeLibType((short)6)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces("ConnectionEvents")]
internal class ConnectionClass // : _Connection, Connection,
ConnectionEvents_Event
{
}
[Guid("2206CCB2-19C1-11D1-89E0-00C04FD7A829")]
[ComImport]
[TypeLibType((short)4160)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
internal interface IDataSourceLocator
{
[DispId(1610743810)]
[return: MarshalAs(UnmanagedType.IDispatch)]
object PromptNew ();
[DispId(1610743811)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool PromptEdit ([In, Out, MarshalAs(UnmanagedType.IDispatch)] ref object
ppADOConnection);
int hWnd
{
[DispId(1610743808)]
get;
[DispId(1610743808)]
set;
}
}
[Guid("00000550-0000-0010-8000-00AA006D2EA4")]
[ComImport]
[TypeLibType((short)4160)]
[DefaultMember("ConnectionString")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
internal interface _Connection
{
[DispId(5)]
void Close ();
object Execute ([MarshalAs(UnmanagedType.BStr)] string CommandText, [Out]
out object RecordsAffected, int Options);
[DispId(7)]
int BeginTrans ();
[DispId(8)]
void CommitTrans ();
[DispId(9)]
void RollbackTrans ();
[DispId(10)]
void Open ([MarshalAs(UnmanagedType.BStr)] string ConnectionString,
[MarshalAs(UnmanagedType.BStr)] string UserID,
[MarshalAs(UnmanagedType.BStr)] string Password, int Options);
[DispId(19)]
object OpenSchema (object Schema, object Restrictions, object SchemaID);
[DispId(21)]
void Cancel ();
int Attributes
{
[DispId(14)]
get;
[DispId(14)]
set;
}
int CommandTimeout
{
[DispId(2)]
get;
[DispId(2)]
set;
}
string ConnectionString
{
[DispId(0)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(0)]
set;
}
int ConnectionTimeout
{
[DispId(3)]
get;
[DispId(3)]
set;
}
object CursorLocation
{
[DispId(15)]
get;
[DispId(15)]
set;
}
string DefaultDatabase
{
[DispId(12)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(12)]
set;
}
object Errors
{
[DispId(11)]
get;
}
object IsolationLevel
{
[DispId(13)]
get;
[DispId(13)]
set;
}
object Mode
{
[DispId(16)]
get;
[DispId(16)]
set;
}
object Properties
{
[DispId(500)]
get;
}
string Provider
{
[DispId(17)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(17)]
set;
}
int State
{
[DispId(18)]
get;
}
string Version
{
[DispId(4)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
}
}