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
VN:F [1.1.6_502]
Rating: 0.0/5 (0 votes cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. Simple WPF ViewModel implementaion with VisualBasic.NET
  2. Manipulate TFS from VB.NET – a starter
  3. VBA - Connect SQL Server from Excel
  4. Dynamic varialbes from text file - PHP
  5. Move a control with mouse on form