Connect using UDL file from .NET
Here is a sample code:
Imports System.Data.OleDb Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK) Then Return Button1.Enabled = False Dim udlfile As String = OpenFileDialog1.FileName Label2.Text = "UDL File: " & udlfile Dim myConnection As OleDbConnection = New OleDbConnection("File Name = " & udlfile) Try myConnection.Open() If (myConnection.State = ConnectionState.Open) Then TextBox1.Text = "Connection opened successfully!" Else TextBox1.Text = "Connection could not be established" End If Catch ex As Exception TextBox1.Text = ex.Message.ToString() Finally myConnection.Close() End Try Button1.Enabled = True End Sub End Class
Related posts:























Leave a Reply
You must be logged in to post a comment.