Beispiel #1
0
        public static bool BuildConnectionString(IntPtr handle, ref string connectionString)
        {
            IntPtr dataInitializePointer;
            IntPtr dataLinksPointer                = CoCreateInstance(DBO.CLSID_DataLinks, IntPtr.Zero, 0x17, DBO.IID_IDataInitialize);
            object dbPromptInitializeObject        = Marshal.GetTypedObjectForIUnknown(dataLinksPointer, typeof(IDBPromptInitialize));
            IDBPromptInitialize dbPromptInitialize = (IDBPromptInitialize)dbPromptInitializeObject;

            dbPromptInitialize.PromptDataSource(IntPtr.Zero, handle, 2, 0, IntPtr.Zero, null,
                                                DBO.IID_IUnknown, out dataInitializePointer);
            if (dataInitializePointer != IntPtr.Zero)
            {
                IDataInitialize dataInitialize = (IDataInitialize)Marshal.GetTypedObjectForIUnknown(dataLinksPointer, typeof(IDataInitialize));
                dataInitialize.GetInitializationString(dataInitializePointer, 1, out connectionString);
                return(true);
            }
            return(false);
        }
Beispiel #2
0
 // Methods
 public DialogResult Show(IntPtr parent)
 {
     try
     {
         CDataLink       link         = new CDataLink();
         Guid            riid         = new Guid("0C733A8B-2A1C-11CE-ADE5-00AA0044773D");
         IDataInitialize initialize   = (IDataInitialize)link;
         object          ppDataSource = null;
         initialize.GetDataSource(null, 1, this.connectionString, ref riid, out ppDataSource);
         ((IDBPromptInitialize)link).PromptDataSource(null, parent, 0x12, 0, 0, null, ref riid, ref ppDataSource);
         initialize.GetInitializationString(ppDataSource, true, out this.connectionString);
     }
     catch (COMException)
     {
         return(DialogResult.Cancel);
     }
     return(DialogResult.OK);
 }