By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Password protected Access file in VB6

P: 9
Have password protected a large Access database and when trying to run the program in VB6 am getting following error when trying to run program:

Not a valid account name or password

***** ON LOAD -- SOURE CODE ******
Expand|Select|Wrap|Line Numbers
  1. strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
  2. strSource = "Data Source=" & App.Path & "\MYDATABASE.MDB;UserID=UNKNOWN VALUE;Password=mypassword"
  3. ' Nothing I put into UserID in the above line appears to work
  4. ' If I remove "UserID=" get same error.
  5. Set rstConnRecordset = New ADODB.Connection
  6. strConnectionRecordset = strProvider & strSource & "Persist Security Info=False"
  7.  
  8. rstConnRecordset.Open strConnectionRecordset
  9. ' Am getting error at above line, when running program
  10.  
  11. Set rstRecord = New ADODB.Recordset
  12.  
  13. With rstRecord
  14.     .ActiveConnection = rstConnRecordset
  15.     .CursorLocation = adUseClient
  16.     .CursorType = adOpenKeyset
  17.     .LockType = adLockOptimistic
  18.     .Open "MYFORM"
  19.     ' above line loads one of two database' involved, each called from separate
  20.     ' routines.
  21. End With
  22.  
  23. If Not rstRecord.BOF And Not rstRecord.EOF Then
  24.     rstRecord.Sort = "RecNum ASC"
  25.     rstRecord.Requery
  26.     Set dgRecordNo.DataSource = rstRecord
  27. End If
  28.  
When loading the database in MS Access, it responds to the assigned password correctly.

Any assistance will be most appriciated.
Jan 29 '08 #1
Share this Question
Share on Google+
4 Replies


9815402440
100+
P: 180
hi
if you want to keep same provider then you need to give system.mdw path
open connection as following:
Expand|Select|Wrap|Line Numbers
  1.     With cn
  2.         .Provider = "Microsoft.Jet.OLEDB.4.0"
  3.         .Properties("Jet OLEDB:System Database") = "C:\Documents and Settings\Manpreet Dhillon\Application Data\Microsoft\Access\system.mdw"
  4.         .Properties("Data Source") = <database path>
  5.         .Properties("Jet OLEDB:Database Password") = <your password>
  6.         .Open
  7.     End With
  8.  
if you want to use system.mdw then you may change provider to msdatashape

as follows
Expand|Select|Wrap|Line Numbers
  1. with cn
  2.                 .Provider = "MsDataShape"
  3.                 .Properties("Data Provider") = "Microsoft.Jet.OLEDB.4.0"
  4.                 .Properties("Data Source") = <database path>
  5.                 .Properties("Extended Properties") = "Jet OLEDB:Database Password= " & <your password>
  6.                 .Open
  7. end with
  8.  
regards
manpreet singh dhillon hoshiarpur
Jan 30 '08 #2

P: 68
Have password protected a large Access database and when trying to run the program in VB6 am getting following error when trying to run program:

Not a valid account name or password

***** ON LOAD -- SOURE CODE ******

strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
strSource = "Data Source=" & App.Path & "\MYDATABASE.MDB;UserID=UNKNOWN VALUE;Password=mypassword"
' Nothing I put into UserID in the above line appears to work
' If I remove "UserID=" get same error.
Set rstConnRecordset = New ADODB.Connection
strConnectionRecordset = strProvider & strSource & "Persist Security Info=False"

rstConnRecordset.Open strConnectionRecordset
' Am getting error at above line, when running program

Set rstRecord = New ADODB.Recordset

With rstRecord
.ActiveConnection = rstConnRecordset
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "MYFORM"
' above line loads one of two database' involved, each called from separate
' routines.
End With

If Not rstRecord.BOF And Not rstRecord.EOF Then
rstRecord.Sort = "RecNum ASC"
rstRecord.Requery
Set dgRecordNo.DataSource = rstRecord
End If

When loading the database in MS Access, it responds to the assigned password correctly.

Any assistance will be most appriciated.

Hi,
You can try this by this following code:

1. strProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
2. strSource = "Data Source=C:\DB.mdb;Jet OLEDB:Database Password=cse;"


3. strConnectionRecordset = strProvider & strSource


If u get success, plz reply.

Get Better.

Regards,
shuvo2k6
Jan 30 '08 #3

P: 9
Thank you very much. At least it now does something.

With your modifications, the program displays two (2), "Now a valid password" pop up screens, but then will enter the program. This is more than I have acchived in the past several hours of research. And days of "trial and error" modifications. Just need to get rid of the two pop-ups.

The only change I made was to add the & App.Path feature.

Source code is now:
Expand|Select|Wrap|Line Numbers
  1. strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
  2. strSource = "Data Source=" & App.Path & "\bibleqz.mdb;Jet OLEDB:Database Password=mypassword"
  3.  
  4. Set rstConnRecordset = New ADODB.Connection
  5. strConnectionRecordset = strProvider & strSource
  6. ' removed this portion per your instructions from above line -- & "Persist
  7. ' Security Info=False"
  8. rstConnRecordset.Open strConnectionRecordset
  9. Set rstRecord = New ADODB.Recordset
  10.  
  11. With rstRecord
  12.     .ActiveConnection = rstConnRecordset
  13.     .CursorLocation = adUseClient
  14.     .CursorType = adOpenKeyset
  15.     .LockType = adLockOptimistic
  16.     .Open "Bquiznt"
  17. End With
  18.  
  19. If Not rstRecord.BOF And Not rstRecord.EOF Then
  20.     rstRecord.Sort = "RecNum ASC"
  21.     rstRecord.Requery
  22.     Set dgRecordNo.DataSource = rstRecord
  23.     Call UpdateTextBoxes
  24. End If
  25.  
Just for information sake, I have only been using VB6 for less than 3 months.

The program is a Biblical Quiz, which includes 525 New Testament and 525 Old Teastament questions, with 4 multiple choice answers.

You can switch between New and Old Testament questions at any time.
You can play by yourself or with up to 6 players.
You can select level of dificulty of questions you want to answer.
If you answer the question incorrectly, you get to read the related verse. Or you can read the related verse at any time.
You can "review" any question at any time. (This does upset the scoreing feature)

Again, Thanks for pointing me in the right direction.
Jan 30 '08 #4

P: 9
******* ISSUE RESOLVED *******

Thanks very much to "shuvo2k6"

Due to the fact that I was in a hurry to try your modifications, I failed to follow up in my source code and due to the fact that I was calling the same basic routine when changing database', once for the New Testament database and once for the Old Testament database, when I first tried your modifications, this caused the two "Not a valid password" issues.

When I updated both locations of calling the databases', it is now working correctly without the "Not a valid password" issues.

Again thank you so much for your interest in others and willingness to help.

As a new programmer in Visual Basic, I have a "LOT" to learn, and if it weren’t for the assistance of people like you, I feel some new programmers, myself included, would give up too early.

Also thanks to those others that offered their assistance, I hope to be able to follow your leads and assist others as I learn more programming techniques.

larystoy
Jan 30 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.