Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friend

I am using VB.net 2008 as front end and Access 2010 as database. In VB.net I have used CRV for viewing crystal report.

Now the problem is that when I'm moving the folder to any other path then some login id and password occurs in crystal report, which shows the wrong path so now is there any relative or dynamic path for viewing crystal report.

Is there any other properties of CRV in which we can give the relative path so that if we move folder from one place to another then also we can see the crystal report? Or is there any other way to set relative path for crystal report?

Hope so you all got the meaning what I want to say. Can any one say in simple way

Sorry but I am new for using this.

Please friends just help me before 21st march because I have presentation on this day.

Thanks to all of u, :)
Posted
Updated 18-Mar-11 15:24pm
v2

This is what I've used in the past, maybe it can point you in the right direction:

Dim strSchemaPath As String = My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData & System.IO.Path.DirectorySeparatorChar & "MySchemaDatabase.mdb"
Dim cdReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocumentcdReportDocument.DataSourceConnections.Item(0).SetConnection(strSchemaPath, "", False)cdReportDocument.SetDataSource(dsMyDataSet)
 
Share this answer
 
Comments
Nuckles Nelson 5-Sep-12 14:22pm    
This ended up helping me a lot, even though it took a minute to figure out the last few lines of code were missing line breaks. In addition, I would warn others to always use cdReportDocument.SetDataSource(dsMyDataSet) instead of cdReportDocument.SetDataSource(dtMyDataTable).
Do you mean dynamic path instead of hard-code path? If yes then store the reports files in web server or application directory(also remote machine path) & call by the below ways.

If it's a web application
C#
report.Load(Server.MapPath("Report1.rpt"));//C#

VB
report.Load(Server.MapPath("Report1.rpt"))'VB.NET

else if it's a windows application
C#
report.Load(Application.StartupPath + "Report1.rpt");//C#

VB
report.Load(Application.StartupPath & "Report1.rpt")'VB.NET

BTW for windows applications you can use other paths like CommonAppDataPath, ExecutablePath, LocalUserAppDataPath, UserAppDataPath. For more info Clickety[^]
 
Share this answer
 
v2
Comments
Member 10433394 12-Mar-14 5:10am    
but is not working in my windows application
thatraja 12-Mar-14 5:32am    
what's the error? 'not working' is not helping me to give you answer. Better create a new question with all details(error message, relevant code, etc.,)
Ok Henry,
see i am using .rpt file with crystal report viewer, now the thing is that i have already given the path of Database file in .rpt file and by which i m able to see that at run time but whenever i am moving my projects folder to some other drive then it shows the dialog box "Database Login". So i just want to see my reports even if i change the path of my folder. and one more thing i hv kept that .rpt file in the same folder.

just help me out from this.

Thanks bro.
 
Share this answer
 
Comments
Kschuler 21-Mar-11 10:33am    
FYI: When you have a question about a possible answer, you will want to use the Add Comment button on that solution instead of posting another solution. Henry did not get any notification that you had a question because you didn't comment on his solution.
swapnilKumbhar 18-Jan-12 2:55am    
But before deploying an application,if project needed to be moved to another PC.
How to set path.
do i have to hard coded it.
I cannot help with your primary problem but you have obviously misunderstood what a 'relative' path is.

A relative path is a path relative to the working directory as opposed to an absolute path which is a path that points to the same location on one file system regardless of the working directory or combined paths. Better explanation than I can give[^].

You have to be careful about your use of technical terms because programming is a science and scientific terms tend to have one, and only one, meaning. :)
 
Share this answer
 
Comments
Member 10420408 6-Dec-13 8:00am    
i got error that crystal report has no table

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