本文整理汇总了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;
}
示例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;
}
}
示例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 { }
}