当前位置: 首页>>代码示例>>C#>>正文


C# Root.Connect方法代码示例

本文整理汇总了C#中Root.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Root.Connect方法的具体用法?C# Root.Connect怎么用?C# Root.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Root的用法示例。


在下文中一共展示了Root.Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        static internal Root Create(esSettings settings)
        {
            Root esMeta = new Root(settings);
            if (!esMeta.Connect(settings.Driver, settings.ConnectionString))
            {
                throw new Exception("Unable to Connect to Database");
            }
            esMeta.Language = "C#";

            return esMeta;
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:11,代码来源:esMetaCreator.cs

示例2: buttonTestConnection_Click

        private void buttonTestConnection_Click(object sender, EventArgs e)
        {
            Cursor oldCursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                Root tempRoot = new Root(Settings);
                Root.UnLoadPlugins();

                DictionaryEntry de = (DictionaryEntry)comboBoxDriver.SelectedItem;
                string driver = (string)de.Value;

                if (!String.IsNullOrEmpty(driver) &&
                    this.textBoxConnectionString.Text != String.Empty &&
                    tempRoot.Connect(driver, this.textBoxConnectionString.Text))
                {
                    esSettingsDriverInfo driverInfo = Settings.FindDriverInfoCollection(driver);
                    if (driverInfo != null)
                    {
                        driverInfo.HasConnected = true;
                    }
                    HideErrorOrStatusMessage();
                    MessageBox.Show("Connection Successful");
                }
                else
                {
                    throw new Exception("Unable to Connect");
                }
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
            }
            finally
            {
                Cursor.Current = oldCursor;
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:40,代码来源:ucSettings.cs

示例3: buttonOleDB_Click

        private void buttonOleDB_Click(object sender, EventArgs e)
        {
            try
            {
                string driver = string.Empty;
                string connstr = string.Empty;

                DictionaryEntry de = (DictionaryEntry)comboBoxDriver.SelectedItem;
                if (null != de.Key)
                {
                    driver = (string)de.Value;
                }
                connstr = this.textBoxConnectionString.Text;

                if (String.IsNullOrEmpty(driver))
                {
                    throw new Exception("You Must Choose a Driver");
                }

                driver = driver.ToUpper();

                if (string.Empty == connstr)
                {
                    connstr = esSettings.GetDefaultConnectionString(driver);
                }

                Type adoType = Type.GetTypeFromProgID("ADODB.Connection");
                if (adoType == null) return;
                object oConn = Activator.CreateInstance(adoType);
                            
                object ret = adoType.InvokeMember("ConnectionString", BindingFlags.SetProperty, null, oConn,
                    new object[] { connstr });

                Type dataLinkType = Type.GetTypeFromProgID("DataLinks");
                if (dataLinkType == null) return;
                object oDialog = Activator.CreateInstance(dataLinkType);

                bool ok = (bool)dataLinkType.InvokeMember("PromptEdit", BindingFlags.InvokeMethod, null, oDialog, new object[] { oConn });

                if (ok)
                {
                    string connString = (string)adoType.InvokeMember("ConnectionString", BindingFlags.GetProperty, null, oConn, null);

                    Root.UnLoadPlugins();
                    Root tempRoot = new Root(Settings);
                    if (tempRoot.Connect(driver, connString))
                    {
                        this.textBoxConnectionString.Text = connString;

                        this.root = new Root(Settings);
                        this.root.Connect(driver, connString);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
            }
            catch { }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:60,代码来源:ucSettings.cs


注:本文中的Root.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。