Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a VB.net application that is connected to an Access database. In the application I am running a Crystal Report that is connected to the same database. In order to be able to add a custom command, I had to connect to the database directly through the CR database expert since using the ADO connection provided by Visual Studio does not allow me to create custom commands.
Everything works just fine inside the Visual Studio 2010 environment, but once deployed on a test machine the report does not work anymore. Setting up the database connection through a ConnectionInfo does not work (CR keeps on asking for a user/pass and there is no pass to the database.
Can anyone tell if it is at all possible to add a custom command to an ADO.NET dataset? If not, what is the proper syntax to connect CR to an Acces database (by providing the Access file name)?

Update: Setting the connection on the DataSourceConnections causes CR to prompt for the user/pass of the Access file. The mdb file (Access 2010)is not password protected (file and workgroup level).

Cheers
Posted
Updated 5-Feb-11 2:58am
v2

1 solution

You need to look at the ReportDocument object, specifically the DataSourceConnections property. I'm guessing that when you deploy your access database is located in a different directory than your development machine and you have to set that for the report. Should look something like this:

ReportDocument1.DataSourceConnections.Item(0).SetConnection(strLocationOfDatabase, "", False)

or with login credentials:
ReportDocument1.DataSourceConnections.Item(0).SetConnection(strLocationOfDatabase, "", "UserName", "Password")


This article[^] looks like it can explain it pretty good. Or you could google[^].

If this is not the case and you deploy differently, please edit your question to specify. Hope this helps.
 
Share this answer
 

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