WHAT I WANT FROM THE FOLLOWING CODE IS THAT IF CONNECTION IS OPEN THEN SWITCH USER TO LOGIN FORM IF CONNECTION IS FAIL TO OPEN THEN SEND USER TO CONFIGURATION FORM WHERE THE NEW PATH FOR DATABASE CAN BE DEFINED. IN THE FOLLWING CODE IF I REMOVE THE DATABASE FROM THE PATH THAT IS DEFINED IN THE CONNECTION STRING THEN IT THROWS EXCEPTION.AND DOESNT SEND USER TO CONFIGURATION FORM.WHAT SHOULD I DO THX IN ADVANCE

Try
            Dim configurationAppSettings As New System.Configuration.AppSettingsReader()
            DbPath = DirectCast(configurationAppSettings.GetValue("DbFilePath", GetType(String)), String)


            'con = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\Develop\trainingapps\PCM\version1.0\PCM\DB\PCM.mdb;Persist Security Info=false")
            'con = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + My.Settings.ConnectionAccess + ";Persist Security Info=false")

            con = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + DbPath + ";Persist Security Info=false")
            Dim cmd As New OleDbCommand
            cmd.Connection = con
            con.Open()

            If con.State = ConnectionState.Open Then
                Return True
            Else
                Return False
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try


    End Function
Member Avatar for Unhnd_Exception
Private Function ConnectionTest() as Boolean
...
    Try
       con.open
       return true
    Catch
       return false
    Finally
       con.Dispose
    End Try
End Function


Private sub button_Click(....) Handles button1.click
     if ConnectionTest then
        'show the login form
     else
        'show the configuration form
     endif

end sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.