本文整理汇总了C#中FdoToolbox.Core.Feature.FdoConnection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# FdoConnection.Close方法的具体用法?C# FdoConnection.Close怎么用?C# FdoConnection.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FdoToolbox.Core.Feature.FdoConnection
的用法示例。
在下文中一共展示了FdoConnection.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override int Execute()
{
CommandStatus retCode;
FdoConnection conn = null;
try
{
conn = new FdoConnection(_provider, _connStr);
conn.Open();
}
catch (OSGeo.FDO.Common.Exception ex)
{
WriteException(ex);
retCode = CommandStatus.E_FAIL_CONNECT;
return (int)retCode;
}
using (conn)
{
using (FdoFeatureService service = conn.CreateFeatureService())
{
try
{
service.CreateDataStore(_dstoreStr);
WriteLine("Data Store Created!");
retCode = CommandStatus.E_OK;
}
catch (OSGeo.FDO.Common.Exception ex)
{
WriteException(ex);
retCode = CommandStatus.E_FAIL_CREATE_DATASTORE;
return (int)retCode;
}
}
if (conn.State != FdoConnectionState.Closed)
conn.Close();
}
return (int)retCode;
}
示例2: TestConnection
public void TestConnection()
{
FdoConnection conn = new FdoConnection("OSGeo.ODBC", string.Format("ConnectionString=\"{0}\"", _view.BuilderObject.ToConnectionString()));
try
{
FdoConnectionState state = conn.Open();
if (state == FdoConnectionState.Open)
{
_view.ShowMessage(null, "Test successful");
conn.Close();
}
else
{
_view.ShowError("Connection test failed");
}
}
catch (FdoException ex)
{
_view.ShowError(ex.InnerException.Message);
}
}
示例3: Test
internal bool Test()
{
using (var conn = new FdoConnection(_view.Provider, GetBaseConnectionString()))
{
if (conn.Open() != FdoConnectionState.Closed)
{
conn.Close();
return true;
}
}
return false;
}
示例4: TestConnection
public void TestConnection()
{
FdoProviderInfo provider = _view.SelectedProvider;
string connStr = ExpressUtility.ConvertFromNameValueCollection(_view.ConnectProperties);
FdoConnection conn = new FdoConnection(provider.Name, connStr);
try
{
FdoConnectionState state = conn.Open();
if (state == FdoConnectionState.Open || state == FdoConnectionState.Pending)
{
_view.ShowMessage(null, "Test successful");
conn.Close();
}
else
{
_view.ShowError("Connection test failed");
}
}
catch (FdoException ex)
{
_view.ShowError(ex.InnerException.Message);
}
finally
{
conn.Dispose();
}
}
示例5: Create
public bool Create()
{
bool ok = true;
FdoConnection conn = new FdoConnection(_view.Provider, GetBaseConnectionString());
bool created = false;
bool cleanup = true;
try
{
using (var svc = conn.CreateFeatureService())
{
try
{
CreateDataStore(svc);
created = true;
}
catch (Exception ex)
{
_view.ShowError(ex);
created = false;
ok = false;
}
}
if (created)
{
//Amend the connection string to include the data store
var builder = new DbConnectionStringBuilder();
builder.ConnectionString = conn.ConnectionString;
builder[_view.DataStoreParameter] = _view.DataStoreName;
conn.ConnectionString = builder.ConnectionString;
conn.Open();
using (var svc = conn.CreateFeatureService())
{
CreateDefaultSpatialContext(svc);
}
}
}
finally
{
if (created)
{
if (File.Exists(_view.SchemaFile))
{
ApplySchemas(conn);
}
if (_view.ConnectOnCreate)
{
_connMgr.AddConnection(_view.ConnectionName, conn);
cleanup = false;
}
}
if (cleanup)
{
conn.Close();
conn.Dispose();
}
}
return ok;
}