Hi how can i pass if my connection is false?
i have a code here
Dim con As New OleDbConnection
Dim dt As New DataTable
Dim ds As New DataSet
con.ConnectionString = ("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & ConMonthEndLocation & "';Extended Properties=Excel 8.0;")
con.Open()
dt.Clear()
ds.Tables.Add(dt)
With Form_Month_End_Report
.ListView_LOB.Columns.Clear()
.ListView_LOB.Items.Clear()
Dim da As New OleDbDataAdapter("Select * from [" & EBU1LOB & "]", con)
da.Fill(dt)
' Importing all the Colum Header of excel to listview Column Header
Dim dc As DataColumn
For Each dc In ds.Tables(0).Columns
Dim ch As New ColumnHeader
ch.Text = dc.ColumnName
ch.Width = 105
.ListView_LOB.Columns.Add(ch)
Next
' Importing all data from Excel to Listview
For Each myRow In dt.Rows
.ListView_LOB.Items.Add(myRow.Item(0))
.ListView_LOB.Items(.ListView_LOB.Items.Count - 1).SubItems.Add(myRow.Item(1))
.ListView_LOB.Items(.ListView_LOB.Items.Count - 1).SubItems.Add(myRow.Item(2))
Next
con.Close()
End With
how can i insert if connection is false then msgbox("Connection failes")
else
put the avove code in here.