Link to home
Start Free TrialLog in
Avatar of slink9
slink9

asked on

Access Database VS2005 Password Protected But No Username

I have an Access database that I have recently had to password protect.  I am using CR8.5 to do the reporting and it worked fine until I password protected the database.  This is the code that worked.

Dim CR As New ReportDocument
            CR.Load(reportPath) ' & ".rpt")
            Dim crParameterDiscreteValue As ParameterDiscreteValue
            Dim crParameterFieldDefinitions As ParameterFieldDefinitions
            Dim crParameterFieldLocation As ParameterFieldDefinition
            Dim crParameterValues As ParameterValues
            crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
            crParameterFieldLocation = crParameterFieldDefinitions.Item("Agency Name")
            crParameterValues = crParameterFieldLocation.CurrentValues
            crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
            crParameterDiscreteValue.Value = ReportParamName
            crParameterValues.Add(crParameterDiscreteValue)
            crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
            crViewer1.ReportSource = CR
            crViewer1.Show()
            Me.WindowState = FormWindowState.Normal
            Me.MaximizeBox = True

What modifications do I need to make to add in the password.  Keep in mind that I do not have a username on the Access database.  Everything that I have seen is pointing toward LOGONINFO and a username seems to be required.  This is CR8.5.
Avatar of JimFive
JimFive
Flag of United States of America image

CR.Database.Tables(1).SetSessionInfo "", Chr(10) & "password"
Avatar of slink9
slink9

ASKER

It looks like that won't do it.  There is not SetSessionInfo.  I tried to do ApplyLogOnInfo with those params and get STRING CANNOT BE CONVERTED.  Other ideas?
Avatar of slink9

ASKER

This command feeds the password.

CR.SetDatabaseLogon("", "password")

but the report still prompts for a username and password when it runs.  Now the passowrd is filled in.  I will keep working around that procedure.
Perhaps:

CR.Database.Tables(1).ConnectionProperties.Item("Database Password") = "passwd"
Avatar of slink9

ASKER

No ConnectionProperties, either.  Is it possible that 8.5 won't let you log into an access table without the username?  I have another program working with CR10 and it successfully connects to a protected database with only database and password sent through SetLogOnInfo.
The default Username for an Access database is Admin the default password is blank.  If you are using a Database Password then that is separate from the User Level Password that you are trying to set with CR.SetDatabaseLogon.  I suspect that you need to remove the CR.SetDatabaseLogon("", "password") line and replace it with something like CR.SetDatabasePassword("password") but I don't find the proper method to use to do that.
--
JimFive

ASKER CERTIFIED SOLUTION
Avatar of JimFive
JimFive
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slink9

ASKER

It must be prompting for a user level password.  The password from thatt command was fed into the password prompt box.  There are no user level passwords set, just a single database access password.  The program is able to feed that password into Access and use the database with no problems.  I am baffled here.
If you're getting the user level password, maybe try giving it the default credentials:

CR.SetDatabaseLogon("Admin", "")
Avatar of slink9

ASKER

I don't know if this is a hint, but all of these solutions (as well as the original) run fine on my development machine but will not run on a target.  There is something on the development system that is feeding the password info to CR and not prompting for it.  I thought feeding the password in the UDL may make a diff but that only made the main program blow (the password is being fed in code, of course).

No uid / pwd combos will work to get into the database for Crystal.  I have tried various things with the password box that comes up.
Perhaps the .DLL on the target machines is at a different version than on your develpment machine?

Is there an ODBC connection defined on the development machine that is not defined on the target?
Avatar of slink9

ASKER

I just copied the Interop and axInterop dll files over into the target directory and that didn't help either.  As far as the password difference goes, I believe that VS2005 will take care of some of the issues.  If that is the case it will explain what is happening here.
Avatar of slink9

ASKER

I am still at a loss.  Any more ideas?  Anyone?
Avatar of Mike McCracken
Are you using the same Access password (workgroup) file on both machines?

You probably need to copy the one from your development machine to the prod environment.

mlmcc
Avatar of slink9

ASKER

No workgroup file.  I have heard that CR10 is required for password protected ACCESS tables.  I am looking at upgrading to 10 for the reports.
Avatar of slink9

ASKER

I can't even find a good book or web site to use as a resource.  Any suggestions as to other resources that may help?
How did you password protect the database?

mlmcc
Avatar of slink9

ASKER

If I open the database it asks for a password and you either know the password and have full access to all tables or you don't and have no acess.  Since there is no user level rights there is no need for a username.
Is this an ACCESS password or is it an Active Dierectory password?

mlmcc
Avatar of slink9

ASKER

Access pwd.  No AD.  This software may be installed in a network environment but it is basically peer-to-peer style data access.
You should be able to use Admin or no username.

mlmcc
Avatar of slink9

ASKER

I know.  That is why this is so baffling.  Nothing seems to work on the target machine yet it seems that anything works in the development environment.
Can you remove the password then add one that has a user name?

mlmcc
Avatar of slink9

ASKER

What I have done now to see things working is remove all of the code between OpenReport and Reportsource/Viewreport.  The report loads, asks me for paramaters and then a password, and runs.  I then added back the block to set the agency name parameter and it only prompts for the date parameters plus the password.

Using this method I get OLE DB (ADO) password prompt with two "Jet System ..." options at the bottom.  Before doing this I did not have these two options.  If I take Admin out of the User ID field and type the password in the Jet Database Password spot I get a report returned.

Keep in mind that these are running and prompting without the LOGONSERVEREX line.  If I add that back with a connection string with no password appended I still get the "Not a valid password" message, no password prompt, and a blank report.

Since I have backed up and made this work, what CR10 command can I use to feed in the JET DATABASE password?
Avatar of slink9

ASKER

By the way, I have made all attempts to move this up to CR10.  Judging from the fact that it works without any connstring or logon I believe this move was successful.
Avatar of slink9

ASKER

This is finally solved, as far as I can tell.  I moved the LOGONSERVEREX to the application instead of the report and it works.
I don't know.  I haven't used CR10 to report against an Acess database.

mlmcc