Subscribe

RSS Feed (xml)

Using the Data Link Properties Dialog Box

Use COM interop with the OLE DB Service Component to display the Data Link Properties dialog box.

You'll need a reference to the Primary Interop Assembly (PIA) for ADO provided in the file ADODB.DLL; select adodb from the .NET tab in Visual Studio .NET's Add Reference Dialog. You'll also need a reference to the Microsoft OLE DB Service Component 1.0 Type Library from the COM tab in Visual Studio .NET's Add Reference Dialog.

The sample code contains a single event handler:
Data Link Dialog Button.Click
Creates and displays a Data Link Properties dialog box using the Microsoft OLE DB Service Component through COM interop.
The C# code is shown here.
Example- File: DataLinkDialogForm.cs
// Namespaces, variables, and constants
using System;

//  . . . 

private void dataLinkDialogButton_Click(object sender, System.EventArgs e)
{
ADODB.Connection conn = new ADODB.Connection( );
object oConn = (object) conn;

MSDASC.DataLinks dlg = new MSDASC.DataLinks( );
dlg.PromptEdit(ref oConn);

connectionStringTextBox.Text = conn.ConnectionString;
}

No comments:

Post a Comment