Link to home
Start Free TrialLog in
Avatar of tomkovic
tomkovicFlag for United States of America

asked on

change crystal report access oledb location at runtime

I want to run a crystal report in my vs2005 web application. It uses two Access databases that are related in the report. The problem is that I used oledb and at design time I had to set the databse location of one of them to the application's app_data folder that is under MyDocuments\microsoft visual studio2005\projects\yada yada yada since that is where it is when I am developing the app. But when it moves to the actual web server that will no longer be the proper path. How do I deal with this? The other database path is OK since it is the same path on both the development machine and the production one. How do I change the location either at run time with code or by setting the thing up at design time?

I have seen some sql server and oracle examples on Google using report.DataSourceConnections(0).SetConnection but it asks for a server name as well as a database name and I have no idea what the server name for an access database is. Also, what is the database name as opposed to the server name? Which one requires the full path in addition to the file name so it can find it? Is this even the thing to use?

This should be a lot eaiser.

You would think this would be a basic issue well-covered by the documentation since VS2005 runs its web sites on its virtual server using the project's file location which is never going to be the same as an actual web server.

So how do I do this, and remember I only need to change the location of one of the databases in the report.

Avatar of Mike McCracken
Mike McCracken

I believe the method is covered in this document
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

mlmcc
Avatar of tomkovic

ASKER

I'm sorry, I'm sure you mean to be helpfull otherwise you would not have posted but saying a 591 page document covers my question doesn't really narrow things down much. I read through the table of contents and I could not see anything that covered ACCESS databases and what I did see had nothing to do with setting and changing the location. I allready have the VS2005 documentation, the crystal reports documentatin and the internet. I need some specific help here.
Give you a basic example here: Basically the Servername here refers to the location of your Access Database File. For web application, you can use Server.MapPath(Foldername)

  'Set the connection information to ConInfo object so that we can apply the
            ' connection information on each table in the reporteport
            ConInfo.ConnectionInfo.UserID = YourDBUserid
            ConInfo.ConnectionInfo.Password = YourDBPwd
            ConInfo.ConnectionInfo.ServerName = YourDBLocation
            ConInfo.ConnectionInfo.DatabaseName = YourDBName

            eReport.FileName = Path
            rptViewer.ParameterFieldInfo = eParameters
            eReport.DataSourceConnections.Item(0).SetConnection(eReportLink, DBName, DBUserid, DBPwd)
...
...
...


Hope it helps.
is YourDBLocation the full path including the database file itself or the full path to the folder containing the file?

The db has no user name or password. Do I put empty strings in there?
ASKER CERTIFIED SOLUTION
Avatar of adriankohws
adriankohws
Flag of Singapore 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