intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Using the Data Link Properties Dialog Box

Chia sẻ: Bui Tuan | Ngày: | Loại File: PDF | Số trang:2

95
lượt xem
3
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

[ Team LiB ] Recipe 1.13 Using the Data Link Properties Dialog Box Problem You want to display the Data Link Properties dialog box from an application so that users can create their own database connections just as they can from the Server Explorer window in the Visual Studio .NET IDE.

Chủ đề:
Lưu

Nội dung Text: Using the Data Link Properties Dialog Box

  1. [ Team LiB ] Recipe 1.13 Using the Data Link Properties Dialog Box Problem You want to display the Data Link Properties dialog box from an application so that users can create their own database connections just as they can from the Server Explorer window in the Visual Studio .NET IDE. Solution 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 in Example 1-10. Example 1-10. 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);
  2. connectionStringTextBox.Text = conn.ConnectionString; } Discussion COM interop can open a Data Link Properties dialog box allowing a user to select an OLE DB provider and set its properties. You can use the results programmatically to construct the connection string for an ADO.NET connection object at runtime with a GUI (graphical user interface). [ Team LiB ]
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2