' it represents the connection of data source Dim con As OleDb.OleDbConnection ' declare a variable to store the string path Dim string_path As String ' set a string path string_path = "c:/IT.xls" 'initailize the oledb connection with the specified connection string con = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & string_path & " ; " & "Extended Properties=Excel 8.0;") Try 'opening connection con.Open() 'validating the connection If ConnectionState.Open Then MsgBox("Connected successfuly") con.Close() Else MsgBox("Unable to connect") End If Catch ex As Exception 'catching errors MsgBox(ex.Message) End Try