0

Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt."

it appears after setting password on my Database. what should i do??

here is my code to path Database

 Private Sub Registration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= |DataDirectory|\Accounts.accdb;Jet OLEDB:Database Password=123;"
End Sub

i got this code in connectionstring.com but also same error appear.

thanks in advance.

3 Answers 3

1

Can you try this Code? And if it doesn't work, can you give the exact error message? If it doesn't recognize the database, You need to install access accdb driver. If it's corrupt, try to compact and repair database.

  con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" 
& Application.StartupPath() & "'\Accounts.accdb;Jet OLEDB:Database Password=123;"
Sign up to request clarification or add additional context in comments.

9 Comments

Forgot to tell you that when using Application.StartupPath(), your database should be in the same directory as your .exe. Which, in your case, is inside the debug folder.
thank you for reply sir but it didnt work. problem already in there. i already installed access accdb driver.
Can you give write down the exact error message? So you mean it does work without the password right?
By the way, I just noticed you're using MS Access 2013. You can check out this website, connectionstrings.com/access for more information. The default encryption scheme for 2013 doesn't work on the current connectionstring you're using. In Access, click on options and choose 2007 encryption method.
i already used that code in the connectionstrings.com sir but same error appears.
|
0

Specify the full path of the database

Private Sub Registration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= c:\Data\Accounts.accdb;Jet OLEDB:Database Password=123;"
End Sub

1 Comment

is your database is really exists in the datadirectory?
0

you just need to do is go to datasource on left side. select the database that you want to connect right click on it and go to property in that first row will represent connection string. Try to use that string for the connection.

There is one example over here of msaccess database connection with vb.net in oledb. Just check it. It will be surely helpful to you.

http://vb.ankwebsoft.in/msaccess-vb-oledb-connection.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.