Is there any simple way to display a standard windows data sources dialog from a winforms application?
I'd like to show it to a user and pick up a system dsn or create a new one and return a datasource name. I haven't found any references to an existing wrappers in .net so I suppose I can only use a win API for that. Any existing solution or a snippet of code would be appreciated.
It seems that it is not possible to get the selected data source name from this dialog. Here is the winapi function which can be used to call this dialog (link):
BOOL SQLManageDataSources(HWND hwnd);
And here is a snippet:
[DllImport("ODBCCP32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool SQLManageDataSources(IntPtr hwnd);
private void ShowDataSourceDialog()
{
SQLManageDataSources(Handle);
}
Argument hwnd is a parent windows handle. Dialog is only displayed for a valid windows handle. Even though I can't select a data source this way, I can at least provide ability to add, change or remove data sources with an existing standard tool. Otherwise I need to create a custom one.