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