Sphere10.Framework.Windows.Forms.Oracle
3.2.0
dotnet add package Sphere10.Framework.Windows.Forms.Oracle --version 3.2.0
NuGet\Install-Package Sphere10.Framework.Windows.Forms.Oracle -Version 3.2.0
<PackageReference Include="Sphere10.Framework.Windows.Forms.Oracle" Version="3.2.0" />
<PackageVersion Include="Sphere10.Framework.Windows.Forms.Oracle" Version="3.2.0" />
<PackageReference Include="Sphere10.Framework.Windows.Forms.Oracle" />
paket add Sphere10.Framework.Windows.Forms.Oracle --version 3.2.0
#r "nuget: Sphere10.Framework.Windows.Forms.Oracle, 3.2.0"
#:package Sphere10.Framework.Windows.Forms.Oracle@3.2.0
#addin nuget:?package=Sphere10.Framework.Windows.Forms.Oracle&version=3.2.0
#tool nuget:?package=Sphere10.Framework.Windows.Forms.Oracle&version=3.2.0
Sphere10.Framework.Windows.Forms.Oracle
Sphere10.Framework.Windows.Forms.Oracle provides Windows Forms editors for Oracle connection settings in desktop applications that use Sphere10 Framework data access. Use OracleConnectionBar where a compact one-row editor fits, and OracleConnectionPanel on a settings page or in a dialog. Both build a connection string for Oracle's managed driver from a host and service or from an existing data source, test it on request and create an OracleDAC from it.
Reference the package
Add the package from your configured feed, and keep its version in step with your other Sphere10 Framework packages:
dotnet add package Sphere10.Framework.Windows.Forms.Oracle
The package depends on Sphere10.Framework.Data.Oracle, which supplies OracleDAC, Tools.Oracle and the Oracle.ManagedDataAccess.Core driver, and on Sphere10.Framework.Windows.Forms. To build against source instead, reference src/Sphere10.Framework.Windows.Forms.Oracle/Sphere10.Framework.Windows.Forms.Oracle.csproj with a ProjectReference.
The project targets net10.0-windows, and a build with a .NET 11 SDK also targets net11.0-windows. Like the other WinForms packages it needs the .NET 10 UI APIs, although the data provider underneath targets net8.0 and later. A consuming project needs a Windows target framework with Windows Forms enabled:
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
Create and use the controls on the application's UI thread. Creating or editing a control never connects, so an Oracle server is needed only to test or open a connection.
Domains
Every folder of Sphere10.Framework.Windows.Forms.Oracle is a domain with its own README, which lists all of its public types.
| Domain | What it provides | Source |
|---|
Project root
Types declared in the project folder itself:
| Type | Kind | Purpose |
|---|---|---|
ModuleConfiguration |
class | Registers OracleConnectionBar and OracleConnectionPanel as named transient ConnectionBarBase and ConnectionPanelBase services under DBMSType.Oracle. |
OracleConnectionBar |
class | One-row ConnectionBarBase editor for the Oracle host, port, service name, user name and password that builds the connection string through Tools.Oracle and creates an OracleDAC. Assigning a connection string shows only its data source, user name and password. |
OracleConnectionPanel |
class | Larger ConnectionPanelBase editor with the same fields as OracleConnectionBar, for a settings page or dialog. |
Controls
Both controls are in the Sphere10.Framework.Windows.Forms.Oracle namespace and edit the same five fields.
| Control | Base class | Use |
|---|---|---|
OracleConnectionBar |
ConnectionBarBase |
One-row editor for a toolbar or header area. Its options button can select an artificial-keys file. |
OracleConnectionPanel |
ConnectionPanelBase |
Larger editor for a settings page or a dialog. |
| Member | Behavior |
|---|---|
Server |
Host name when Database holds a service, otherwise the complete Oracle data source. The UI labels this field Host. |
Database, DatabaseName |
Oracle service name. The UI labels this field Service. DatabaseName returns the Database text and does not query the server. |
Port |
Port as text, used only with a host and a service. A blank port means 1521. |
Username, Password |
Account name and password. A blank value is left out of the string. The password box masks its text, but both properties return plain text. |
ConnectionString |
Builds the string with Tools.Oracle.CreateConnectionString, or loads the data source and credentials of an assigned string through OracleConnectionStringBuilder. |
GetDAC() |
Returns a new OracleDAC as IDAC without opening a connection. |
TestConnection() |
Opens and closes a test connection, and returns Task<Result>. |
ArtificialKeysFile |
Bar only. Path of an artificial-keys XML file. The options button sets it through SelectArtificialKeysFile() and can clear it again. GetDAC() loads the file into each new DAC, so that GetSchema() includes the keys it declares. |
ConnectionString is hidden from the Windows Forms designer, but the field properties are not. Assign credentials at runtime so that they never reach designer-generated code.
Edit and test a connection
Place the panel on a designer-authored dialog, form or screen like any other control, and host OracleConnectionBar the same way where space is limited. The code-behind below belongs to a dialog whose designer file declares _connectionPanel (an OracleConnectionPanel), _testButton and _statusLabel, wires _testButton.Click, and sets the DialogResult of its OK and Cancel buttons.
using System;
using System.ComponentModel;
using System.Windows.Forms;
public partial class DatabaseSettingsDialog : Form {
public DatabaseSettingsDialog() {
InitializeComponent();
}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string ConnectionString {
get => _connectionPanel.ConnectionString;
set => _connectionPanel.ConnectionString = value;
}
private async void _testButton_Click(object sender, EventArgs e) {
_testButton.Enabled = false;
try {
var result = await _connectionPanel.TestConnection();
if (!IsDisposed)
_statusLabel.Text = result.IsSuccess ? "Connection succeeded." : string.Join(Environment.NewLine, result.ErrorMessages);
} catch (Exception error) {
// Settings that cannot form a connection string throw instead of failing the result.
if (!IsDisposed)
_statusLabel.Text = error.Message;
} finally {
if (!IsDisposed)
_testButton.Enabled = true;
}
}
}
Show the dialog with the saved string, and keep the edited string only when the user accepts it:
using var dialog = new DatabaseSettingsDialog { ConnectionString = savedConnectionString };
if (dialog.ShowDialog(owner) == DialogResult.OK)
savedConnectionString = dialog.ConnectionString;
The editors only collect settings. They do not save profiles, discover servers or create databases, and they never hold a connection:
TestConnection()builds the connection string on the calling thread, then opens and disposes a DAC scope on a thread-pool task. A connection failure becomes an error in the returnedResult, and no connection stays open afterwards. A successful test shows that a connection opened, not that the application's tables or permissions are in place. The method takes no cancellation token.- Building the string can throw before the test starts. The bar throws a
FormatExceptionfor port text that is not a number, and loading itsArtificialKeysFilecan also fail. - When the application needs the database, call
GetDAC()on the editor or constructnew OracleDAC(connectionString), then callEnterScope()for each unit of work and dispose the scope. The DAC itself is not disposable, and the scope owns the connection. StateChanged, inherited fromUserControlEx, is a parameterless event that is raised when a field changes after the control has loaded. It reports edits, not connectivity.
For example, this unit of work deletes the stored sessions in one transaction on the accepted string:
using Sphere10.Framework.Data;
var dac = new OracleDAC(savedConnectionString);
using (var scope = dac.EnterScope()) {
scope.BeginTransaction();
dac.ExecuteNonQuery("DELETE FROM sessions");
scope.Commit();
}
Disposing the scope does not commit, so call Commit() explicitly.
Host an editor in code
The editors also work without the designer. Use this as Program.cs in a Windows Forms application that references the package. Nothing connects on startup, and Test connection contacts the server with the entered settings.
using System;
using System.Drawing;
using System.Windows.Forms;
using Sphere10.Framework.Windows.Forms.Oracle;
using Application = System.Windows.Forms.Application;
namespace ReadmeExamples.OracleDirect;
internal static class Program {
[STAThread]
private static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using var window = new Form { Text = "Oracle connection", ClientSize = new Size(640, 260) };
var editor = new OracleConnectionPanel {
Dock = DockStyle.Fill,
Server = "localhost",
Database = "FREEPDB1",
Username = "app_user"
};
var status = new Label { Dock = DockStyle.Bottom, Height = 44, Text = "Enter your connection details." };
var testButton = new Button { Dock = DockStyle.Bottom, Height = 32, Text = "Test connection" };
testButton.Click += async (sender, args) => {
testButton.Enabled = false;
try {
var result = await editor.TestConnection();
if (!window.IsDisposed)
status.Text = result.IsSuccess ? "Connection succeeded." : string.Join(Environment.NewLine, result.ErrorMessages);
} catch (Exception error) {
// Settings that cannot form a connection string throw instead of failing the result.
if (!window.IsDisposed)
status.Text = error.Message;
} finally {
if (!testButton.IsDisposed)
testButton.Enabled = true;
}
};
window.Controls.Add(editor);
window.Controls.Add(status);
window.Controls.Add(testButton);
Application.Run(window);
}
}
The form owns and disposes the child controls. With a blank port, these settings connect to the FREEPDB1 service on port 1521. To use the bar instead, host OracleConnectionBar the same way and call the same ConnectionString, GetDAC() and TestConnection() members.
Connection string behavior
The editors build the data source in one of two ways, depending on whether Database holds a service name:
- With a host in
Serverand a service inDatabase, the editor writes a TCP descriptor. For example,Server = "localhost",Database = "FREEPDB1"and a blankPortproduce the data source(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=FREEPDB1))).Databasenames a service, not an Oracle SID. - With
Databaseblank, the editor usesServerunchanged as the data source, soServercan hold a TNS alias, an Easy Connect string or a full descriptor.Portis ignored in this mode.
Loading a string does not parse a descriptor back into these fields. Assigning ConnectionString copies the data source into Server and clears Database and Port, so DatabaseName is blank after loading. Enter a service in Database again only after replacing Server with a plain host name.
- The editors rebuild the string from their fields, so other settings in an assigned string are dropped, such as pooling or timeouts. To keep such settings, read
ConnectionString, add them withOracleConnectionStringBuilder, and constructOracleDACfrom the result.GetDAC()andTestConnection()always use the rebuilt string. - The bar parses the port strictly. The panel leaves out port text that it cannot parse, which means port 1521 for a host and service. Validate the port in the application when invalid input must be rejected.
- The setter does not catch errors from
OracleConnectionStringBuilder, so assigning a string that it rejects throws. - Connection strings contain the password, so do not log or display them.
Use the generic provider selector
DatabaseConnectionPanel and DatabaseConnectionBar in Sphere10.Framework.Windows.Forms let the user choose a database engine and then show that engine's editor. They resolve the editors as named framework services, so add this package's module to the application's startup code:
Sphere10Framework.Instance
.BuildWinFormsApplication()
// ... the application's existing configuration and modules ...
.AddModule<Sphere10.Framework.Windows.Forms.Oracle.ModuleConfiguration>()
.StartWinFormsApplication();
ModuleConfiguration registers OracleConnectionBar and OracleConnectionPanel as transient services named nameof(DBMSType.Oracle). Referencing the package does not register them, and a directly hosted Oracle editor needs no module.
- A selector constructed before the framework has started, for example in the Windows Forms designer, finds no service provider and lists no engines, so construct it after startup. Switching engines disposes the previous editor.
- The engine list contains only registered providers. Setting
SelectedDBMSTypeto an unregistered engine leaves the current editor selected. - Set
SelectedDBMSType = DBMSType.Oraclebefore assigningConnectionString, because the selector passes the string to its current editor. Databasereturns the engine and the string together as aDBReference, and the bar also accepts one.DACFactory.CreateDAC(reference.DBMSType, reference.ConnectionString)recreates the DAC from a saved reference.DatabaseConnectionPanelraisesDBMSTypeChanged(panel, dbmsType)when the selected engine changes.DatabaseConnectionBarhas no such event.
This complete Program.cs starts only the modules that the selector needs, shows it with Oracle selected and ends the framework after the window closes:
using System;
using System.Drawing;
using System.Windows.Forms;
using Sphere10.Framework.Application;
using Sphere10.Framework.Data;
using Sphere10.Framework.Windows.Forms;
using ProviderModule = Sphere10.Framework.Windows.Forms.Oracle.ModuleConfiguration;
using WinFormsModule = Sphere10.Framework.Windows.Forms.ModuleConfiguration;
using Application = System.Windows.Forms.Application;
namespace ReadmeExamples.OracleSelector;
internal static class Program {
[STAThread]
private static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var framework = Sphere10Framework.Instance;
framework.Build()
.AddModule<WinFormsModule>()
.AddModule<ProviderModule>()
.Start();
using var shutdown = Tools.Scope.ExecuteOnDispose(framework.EndFramework);
using var window = new Form { Text = "Database connection", ClientSize = new Size(660, 220) };
var selector = new DatabaseConnectionPanel {
Dock = DockStyle.Fill,
SelectedDBMSType = DBMSType.Oracle
};
window.Controls.Add(selector);
Application.Run(window);
}
}
In an existing framework application, add the module to its startup builder instead of starting a second framework. Register the modules of other providers to add their engines to the selector.
Save the selector's Database to keep the engine with the string, and recreate the DAC from it later:
using Sphere10.Framework.Data;
var saved = selector.Database;
var dac = DACFactory.CreateDAC(saved.DBMSType, saved.ConnectionString);
using (dac.EnterScope()) {
var customers = dac.ExecuteScalar<long>("SELECT COUNT(*) FROM customers");
}
Try the controls
The WinForms Tester hosts both editors. Run it from the repository root on Windows:
dotnet run --project utils/Sphere10.Framework.Utils.WinFormsTester -c Release -f net10.0-windows -p:BuildRevision=0
- Controls > Input > All controls by class name opens the control catalog. Search for
OracleConnectionto edit sample settings, which never connect on their own. - Integration > Connections > Database Connection Panel and Database Connection Bar show the generic selectors with every provider module registered. Choose Oracle, enter the settings of a reachable server and click Test connection.
Build from source
Build the project and pack it on its own from the repository root on Windows:
dotnet build src/Sphere10.Framework.Windows.Forms.Oracle/Sphere10.Framework.Windows.Forms.Oracle.csproj -c Release -p:BuildRevision=0
dotnet pack src/Sphere10.Framework.Windows.Forms.Oracle/Sphere10.Framework.Windows.Forms.Oracle.csproj -c Release --no-build -p:BuildRevision=0
-p:BuildRevision=0 keeps a development build from taking the next local build number. The root README explains build numbering, and how scripts/pack.ps1 packs the whole package set. The project packs this file as its NuGet readme, and Directory.Packages.props sets the driver version.
OracleConnectionBar.csandOracleConnectionPanel.csbuild the string withTools.Oracle.CreateConnectionStringand load it withOracleConnectionStringBuilder.ModuleConfiguration.csregisters the named services.ConnectionBarBaseandConnectionPanelBaseimplementIDatabaseConnectionProvider, including the sharedGetDAC()andTestConnection()logic.
Related documentation
- Windows Forms library for the generic selectors and the base classes.
- Oracle data provider for
OracleDAC,Tools.Oracleand the provider's limits. - Data access for DAC scopes, transactions and artificial keys.
- Application startup and modules.
- Database connection editors, which compares the editors of every provider.
- The other provider editors for SQL Server, SQLite, Firebird, MySQL and PostgreSQL.
License and author
License: MIT License
Author: Herman Schoenfeld (sphere10.com)
Copyright: © 2018-Present Herman Schoenfeld. All rights reserved.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. net11.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- Sphere10.Framework.Data.Oracle (>= 3.2.0)
- Sphere10.Framework.Windows.Forms (>= 3.2.0)
-
net11.0-windows7.0
- Sphere10.Framework.Data.Oracle (>= 3.2.0)
- Sphere10.Framework.Windows.Forms (>= 3.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.0 | 0 | 11/24/2026 |
| 3.2.0-ci.173.45375449609.1 | 0 | 11/24/2026 |
| 3.2.0-ci.171.45374063975.1 | 0 | 11/24/2026 |
| 3.2.0-ci.169.45350717665.1 | 0 | 11/24/2026 |
| 3.2.0-ci.168.45166918016.1 | 41 | 11/23/2026 |
| 3.2.0-ci.163.43664782937.1 | 60 | 11/15/2026 |
| 3.2.0-ci.160.43660265392.1 | 59 | 11/15/2026 |
| 3.2.0-ci.159.43537748063.1 | 60 | 11/14/2026 |
| 3.2.0-ci.158.43536665157.1 | 62 | 11/14/2026 |
| 3.2.0-ci.157.43350632870.1 | 62 | 11/13/2026 |
| 3.2.0-ci.156.43233095581.1 | 59 | 11/12/2026 |
| 3.1.2 | 139 | 9/9/2026 |
| 3.1.1 | 137 | 9/8/2026 |
| 3.1.0 | 116 | 9/7/2026 |