СообЧа > База Знаний > Программирование > .NET

Вопрос

Как можно в .NET вывести стандартный диалог создания соединения с БД?

Ответ

Function CreateConnString(Optional ByVal parentForm As Form = Nothing)
As String
Dim dataLink As Object =
Microsoft.VisualBasic.Interaction.CreateObject("DataLinks")

'On Error Resume Next
If Not parentForm Is Nothing Then
dataLink.hWnd = parentForm.Handle.ToInt32()
End If

' display the dialog
Dim o As Object = dataLink.PromptNew()
If o Is Nothing Then Return "" Else Return o.ConnectionString.ToString()

End Function

'===============================================
'============= variant 2========================
'Need add reference to COM component
'MS OLEDB Service Component 1.0 Type Library

Function CreateConnString(Optional ByVal parentForm As Form = Nothing)
As String
'Dim dataLink As Object = CreateObject("DataLinks")
Dim dataLink As New MSDASC.DataLinks()

'On Error Resume Next
If Not parentForm Is Nothing Then
dataLink.hWnd = parentForm.Handle.ToInt32()
End If

' display the dialog
Dim o As Object = dataLink.PromptNew()
If o Is Nothing Then Return "" Else Return o.ConnectionString.ToString()

End Function
'===============================================
'To edit existing connection use dataLink.PromptEdit()

Павел Сурменок



Copyright © 2000-2004 Сообщество Чайников
Контактная информация