Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im using vb2010 and ms access to create a simple app
now when i add a password in my ms access the system can't access. there is an error popping out

I tried the code below to locate the ms access database.


Also can crystal report generate report from a protected Ms Access Database?

What I have tried:

con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Planz.mdb")
Posted
Updated 9-Sep-21 0:28am
v2
Comments
Richard MacCutchan 9-Sep-21 5:47am    
" there is an error popping out"
Don't you think the actual text, and where it occurs, might be useful information?

Error messages are a must when troubleshooting problems.

But, this one appears to be very easy. Just look up the connection string at Access connection strings - ConnectionStrings.com[^]
 
Share this answer
 
Comments
Beginner213456 9-Sep-21 2:13am    
i have read it . thanks
but which is better?
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Planz.mdb;Persist Security Info=False;"
or
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\planz.mdb"
Dave Kreskowiak 9-Sep-21 7:17am    
There is no "better". There is "what's more appropriate".

Which one to use depends on your app, and how you deploy it.
Beginner213456 16-Sep-21 22:46pm    
I want to deploy the exe and the database file in the same folder.
should i use
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Planz.mdb;Jet OLEDB:Database Password=ccc111;"
Dave Kreskowiak 16-Sep-21 22:53pm    
No, no, no, no, no. The database is NOT going to be in the same folder as the executable. Your app installs under Program Files, which is ReadOnly to normal users. That means you cannot put your Access database anywhere under that folder.

Read: Where Should I Store My Data?[^]
Beginner213456 9-Sep-21 2:17am    
I have updated my question,
can crystal report generate reports from protected ms access database.
i tried but it seems i cant add tables from the database in the crystal report
To answer your first comment to solution 1 - ACE supersedes JET and is fully backward compatible. It will also run on 64bit whereas JET will not.

In response to your second comment to solution 1 - you are not using the correct connection string. Read the information on the link that Dave gave you
VB
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Planz.mdb;Jet OLEDB:Database Password=MyDbPassword;")
replacing "MyDbPassword" with the actual password. Make sure your password is 14 characters or less.
 
Share this answer
 
Comments
Beginner213456 17-Sep-21 4:21am    
I tried the code you provided
but i have an error
saying
Not a valid password
Highlighting
the code:
Me.Table1TableAdapter.Fill(Me.PlanzDataSet.Table1)
in the Form1_Load
CHill60 17-Sep-21 6:53am    
Then perhaps you mistyped the password in the connection string? Where I typed "MyDbPassword" YOU have to type YOUR password
Beginner213456 19-Sep-21 21:21pm    
I have typed it properly. they are perfectly the same.
My database is linked to my project using the binding source
CHill60 23-Sep-21 15:05pm    
If you are getting a message saying "Not a valid Password" and the passwords definitely match then your password is too long

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900