open UDL Dialog at runtime
-
Hi All, When we double click a .udl file it opens the configuration dialog for connectionstring. What if i would like to open this dialog box at runtime using C# or VB.net? Thanx in advance. sorry for my bad English.
-
Write click on your .udl file and choose OPEN WITH--->CHOOSE PROGRAM and then choose VS.NET to open it. Mazy No sig. available now.
-
Hi, Infact i wana say that i would like to openthe UDL dialog on soem event e.g OnButton_Click eent i would like to Open this dialog and retrieve the connection string. Can u provide some clue. Thanx in Advance:) sorry for my bad English.
-
I think this will work:
Process.Start("path to VS.NET","path to your .udl file");
But I'm not exactly sure ,maybe you need to pass file path in first argument too. Mazy No sig. available now.
Actually, he just wants to open the file with its associated program / shell handler, so the following should be used:
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "path/to/file.udl";
psi.UseShellExecute = true;
Process.Start(psi);ShellExecute(Ex)
is what is executed when you double-click a file (or do whatever is the default action based on shell settings). You can also pass different verbs, like "open", "edit", "print", etc., so long as they are supported by the file type association in the registry.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Hi All, When we double click a .udl file it opens the configuration dialog for connectionstring. What if i would like to open this dialog box at runtime using C# or VB.net? Thanx in advance. sorry for my bad English.
Take a look at: HOW TO: Build a Connection String Programmatically in ADO.NET by Using Visual C# .NET[^] For a more reusable sample, try this code:
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using ADODB;
using MSDASC;public sealed class DataLinkDialog : CommonDialog
{
private string _connectionString;/// <summary> /// Constructor /// </summary> /// <param name="connectionString">The initial connection string</param> public DataLinkDialog(string connectionString) { \_connectionString = connectionString; } /// <summary> /// Constructor /// </summary> public DataLinkDialog() { \_connectionString = string.Empty; } /// <summary> /// Gets or sets the connection string /// </summary> public string ConnectionString { get { return \_connectionString; } set { \_connectionString = value; } } /// <summary> /// Resets the properties of the dialog box /// to their default values. /// </summary> public override void Reset() { \_connectionString = string.Empty; } /// <summary> /// Displays the dialog box. /// </summary> /// <param name="hwndOwner"> /// A value that represents the window handle of the /// owner window for the common dialog box. /// </param> /// <returns> /// true if the dialog box was successfully run; /// otherwise, false. /// </returns> protected override bool RunDialog(IntPtr hwndOwner) { DataLinks dl = new DataLinksClass(); try { if (null == \_connectionString || 0 == \_connectionString.Length) { object ret = dl.PromptNew(); if (null == ret) { return false; } else { \_connectionString = ((ADODB.\_Connection)ret).ConnectionString; Marshal.ReleaseComObject(ret); return true; } } else { Connection cn = new Connecti