views:

222

answers:

1

I am opening a MS Access DB which is Password protected in vb.net using the folloing code:

Try
   oDB = oDBEngine.OpenDatabase(Name:=strFullFileName, Options:=False, _
                               ReadOnly:=False, Connect:="")

Catch ex As Exception

   strError = "File is password protected."
   Exit Function

End Try

But while releasing the object the msaccess.exe opens up automatically.

 **System.Runtime.InteropServices.Marshal.ReleaseComObject(object)**

Could anyone help me, how to resolve the issue....

+3  A: 

Rather than using OpenDatabase to get the error, how about a connection string?

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
       "Data Source=" & strFile & ";" & _
       "Persist Security Info=False"

This will also give an error if a password is not supplied.

Remou
Hi Remou,You are genius,It is working.Thank you.
Suman