Machaira Posted February 25, 2003 Posted February 25, 2003 Wasn't sure where else to post this, so I'll try here. :) I have found no way to create a report so that the database it uses contains no path information. I want the report to look for the database in the same folder as the report without a hard-coded path. This is using version 9 of Crystal Reports with VB.NET. Quote Here's what I'm up to.
zzdv Posted March 12, 2003 Posted March 12, 2003 I have the same problem, actually i have found no solution... Quote
rustyd Posted March 12, 2003 Posted March 12, 2003 I haven't used Crystal Reports with .NET yet, but Crytal Reports 7 has a Database -> Set Location... menu option. Click that and the tables in the report show up. The path is defaulted to current directory and if you move the report is tries to find the database in the path where the report is created. If you click the button Same as Report, the path is removed and your report will run as long as it is in the same directory as the database. Quote rustyd
rustyd Posted March 12, 2003 Posted March 12, 2003 Sorry, after adding a Crystal Report to a project and trying to set the location to same as report, I found out that option does not exist in v9.0. But I did a little research at Crystal Decisions and found this article: http://support.crystaldecisions.com/library/kbase/articles/c2010490.asp Hope this helps. Quote rustyd
mrdutchie Posted September 5, 2003 Posted September 5, 2003 (edited) nm Edited September 5, 2003 by mrdutchie Quote
andrux Posted March 11, 2009 Posted March 11, 2009 Hi, all It took me a lot of hours of surfing the web trying to find a solution to this exact problem, and after giving up searching for an answer, I decided to try my own way... and after a couple of hours playing around with Crystal Reports (mine is for Visual Studio 2008, I think is CR 9...) I found a solution. All we need to do is use a Datatable to fill in the report. Here´s how I did it: I first created a Dataset, added a new Datatable (myDataTable) and added a few columns to it (Col1, Col2). Then I created the report (myreport), and set the source to be the Dataset I created before, that filled in the fields in the report with the fields I added to my Datatable. Then I went to the actual code that loads my report, in my case it's the Load event on the form containing the Crystal Reports Viewer (myCRViewer). Here's the code: Dim rep As New myreport Dim dt As New myDataTable Dim strQuery As String = "SELECT Col1, Col2 FROM myDB WHERE Col2 > 0" Dim con As New OdbcConnection("Dsn=dBASE Files;defaultdir=C:\DB;driverid=277;fil=dBASE IV;maxbuffersize=2048;pagetimeout=5") dt.Columns.Clear() dt.Rows.Clear() dt.Columns.Add("Col1") dt.Columns.Add("Col2") Dim objCommand As OdbcCommand = New OdbcCommand(strQuery, con) Dim objAdapter = New OdbcDataAdapter(objCommand) objAdapter.SelectCommand = objCommand objAdapter.Fill(dt) rep.SetDataSource(dt) myCRViewer.ReportSource = rep We just need to build the path into the connection string, using either a textbox, a string variable or even a user selection instead of "C:\myDB" and we're ready to work! This actually solved two of my problems, it was of course setting the location for my DBF database and also the use of SQL queries which I wasn't able to use, and had to use the RecordSelectionFormula... Hope this helps you guys get back in track! By the way, after making sure it worked, I even deleted the dataset and it still works. If you have any problems getting this code to work, just let me know, because I edited a little bit first to post it here... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.