Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resetting database password after compacting

Status
Not open for further replies.

33216CLC

Programmer
Aug 17, 2000
173
0
0
BS
VB6

Hi,

I have been searching for months for some code to reset the password to an Access mdb file that is used as the backend database for my software. I would like to compact the database everytime the program is opened. I have the code for compacting, but when I use it, I loose to password to the database and am able to open it without having to log in.

May I please have some CODE to do this, PLEASE????

Thanks
 
Dim JRO As JRO.JetEngine
Dim stSource
Dim stTarget

PW$ = "Password"

Set JRO = New JRO.JetEngine

Access.Close

stSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=pdp.mdb;Jet OLEDB:Database Password=" & PW$

stTarget = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=pdp1.mdb;Jet OLEDB:Engine Type=5;Jet OLEDB:Database Password=" & PW$

Call JRO.CompactDatabase(stSource, stTarget)

Kill "pdp.mdb"
Name "pdp1.mdb" As "pdp.mdb"

Set Access = New ADODB.Connection
Access.CursorLocation = adUseClient
On Error GoTo errCheck
Access.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=pdp.mdb;Jet OLEDB:Database Password=" & PW$
On Error GoTo 0
Exit Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top