whizkid123 Posted January 14, 2003 Posted January 14, 2003 Hi! I'm working on VB.Net and this is the first time that I'm using crystal reports. I'm not able to find any basic documentation regarding how do we go about it. I have created & designed a report. I'm using MS Access and by connecting to it have got the list of tables in the database fields explorer. Now after that, I've added a CRV on my form and set the datasource to a dataset that I've created programatically. When I view the report, it does not even load the design elements in my report. It's fully blank. The dataset is not blank. Can anybody please help me with this. If there are any tutorials, sample codes on this and if somebody could point me to it, it would be really helpful. Thanx! Quote
Leaders quwiltw Posted January 16, 2003 Leaders Posted January 16, 2003 I've got Enterprise Architect edition and it came with an example for both WinForm and WebForms. Check here or the equivelent location on your box: C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Code\WinForms\VB Quote --tim
ashrobo Posted May 30, 2003 Posted May 30, 2003 sorry for digging up an old thread. whizkid123, i'm facing the same situation as you. have you managed to solve the problem? i've looked at the example but it's a tad simple.. -ashrobo Quote
hog Posted June 3, 2003 Posted June 3, 2003 after you have created your dataset pass it to the form that will display your report and set the forms private dataset variable to the dataset being passed to the form Private m_dsReportSource As System.Data.DataSet Public Sub New(ByVal dsReportSource As System.Data.DataSet) MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call ' set the forms dataset variable to passed dataset m_dsReportSource = dsReportSource End Sub then setup your report as follows.... Private Sub CrystalReportViewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load myReport = New repWhatEver() myReport.SetDataSource(m_dsReportSource) Me.CrystalReportViewer1.ReportSource = myReport End Sub Quote My website
ashrobo Posted June 3, 2003 Posted June 3, 2003 thanks a bunch, hog! but how do i add the dataset's fields into the report? -ashrobo Quote
hog Posted June 3, 2003 Posted June 3, 2003 Maybe not the most elegant way but I create a temp dataadapter and dataset on the form in design mode to make all the required fields accessible. Then when the report is as I want it I just assign the dynamic dataset to the report at runtime and all works a treat Quote My website
ashrobo Posted June 4, 2003 Posted June 4, 2003 i tried it but it didn't work as i thought it would.. when the crystal report viewer was loaded, it loads the crystal report which in turn asked me about the logon details. any clues? -ashrobo Quote
Madz Posted June 4, 2003 Posted June 4, 2003 (edited) This example will show you how you can dynamicaly load data in to a report and view in a CRV Imports CrystalDecisions.CrystalReports Imports System.Data Imports System.Data.SqlClient Public Class frmDeliveryReport Inherits System.Windows.Forms.Form Public myRpt As New rptOrderDelivery() Public intDeliveryId As Integer <HERE FORM DESIGNER CODE> Private Sub frmDeliveryReport_Load() Handles MyBase.Load Dim myAdapter As SqlDataAdapter = New SqlDataAdapter("SELECT Some Day Where OrderDelivery.DeliveryID = " & intDeliveryId, mySQL) Dim myDS As DataSet = New DataSet() myAdapter.Fill(myDS) myRpt.SetDataSource(myDS.Tables(0)) crvDEL.ReportSource = myRpt crvDEL.Zoom(2) End Sub Remeber these Steps 1- Design a Crystal Report from ADO.NET generated XML file. you can create it from adding a new XML Schema File or asking and Adapter to generate a data set. this file is nothing just a sequence of colums which your Query will return. 2- Then on the Report Form you first need to instentiate that report file ang generate some data set from some query 3- then From that generated data set , set the datasource property of Report to that data set. so the report loads data in it 4- and at the end you need to set to CRV report source property to that generated report. Edited June 4, 2003 by Madz Quote The one and only Dr. Madz eee-m@il
hog Posted June 4, 2003 Posted June 4, 2003 Madz, haven't tried your approach, but just looking at the steps required it seems to be a lot of effort whereby simply having a temp dataset & dataadapter in design mode would suffice. Quote My website
ashrobo Posted June 4, 2003 Posted June 4, 2003 a million thanks to you, madz.. :) finally, i'm able to create a report for 1 record. now the problem is the "details" which in my case, is invoice details, cannot be displayed. i dragged the field "itemno" down onto the report and when i run it, i get "query engine error". - ashrobo Quote
ashrobo Posted June 4, 2003 Posted June 4, 2003 Madz, haven't tried your approach, but just looking at the steps required it seems to be a lot of effort whereby simply having a temp dataset & dataadapter in design mode would suffice. in fact, i only managed to get it going after following Madz's steps.. hog, i thought Madz's steps were similar to yours. he has a XML schema file while you have a dataset and dataadapter. thanks guys/gals, - ashrobo Quote
Madz Posted June 4, 2003 Posted June 4, 2003 Dear There is nothing difficult with it. Just Do these Steps 1- Generate an XML file this is required for Crytal Report if you want to use ADO.NET with Report. its much easier to generate it Just you need to add an XML Schema File to your Solution. then from Server Explorer Expand the SQL Server List and then Drag the Desired Table to the File. 2- Then FRom CR Report Designer choose ADO.NET it will ask you to open some XML File then path to that file and choose the columns which you want to show on table. 3- then design the Report with code above. and Query the Table which you want to show on report. and fill the report with that. the above example it from a real project this shows the Delivery Report on a paid order. Which shows the desired delivery report and get it by report id. Here an other example which shows the sales record on report it is much easier. and same as the old one Public rptDel As New rptPaymentsReport() Private Sub frmDealerReport_Load() Handles MyBase.Load On Error Resume Next Dim myAdapter As SqlDataAdapter = New SqlDataAdapter(strQuery, mySQL) Dim myDs As DataSet = New DataSet() myAdapter.Fill(myDs) rptDel.SetDataSource(myDs.Tables(0)) crvDealer.ReportSource = rptDel crvDealer.Zoom(2) crvDealer.RefreshReport() End Sub Quote The one and only Dr. Madz eee-m@il
ashrobo Posted June 4, 2003 Posted June 4, 2003 urmm, i am able to display the invoice headers based on the steps that you've listed out, Madz.. it's the Invoice Details that are not coming out now.. fields such as "Invoice.InvoiceNo", "Invoice.InvoiceDate", etc are fine. however, if i add the field "InvOrders.ItemNo", the error will occur but if i add the field "InvOrders.InvoiceNo", no error. :confused: -ashrobo Quote
hog Posted June 4, 2003 Posted June 4, 2003 I suppose it's each to his own. I've done loads of reports using my method with no problem. Just seems like there is more steps in your method. Anyway whichever way it's done they both work so that's all that matters :-) Quote My website
hog Posted June 4, 2003 Posted June 4, 2003 OK madz, I'm always up for trying something new.... I have added a blank xml file to my project, but if I try to drag a table from my access connection it does not allow me to do so. Quote My website
ashrobo Posted June 5, 2003 Posted June 5, 2003 OK madz, I'm always up for trying something new.... I have added a blank xml file to my project, but if I try to drag a table from my access connection it does not allow me to do so. really? i could just drag the table over without any errors.. Quote
Madz Posted June 5, 2003 Posted June 5, 2003 I dont thing so, there might be some thing missing coz it is so much easy just drag the table to designer and it will add a table. Quote The one and only Dr. Madz eee-m@il
hog Posted June 5, 2003 Posted June 5, 2003 No...it won't have it? I add a blank xml file to my solution I expand the tables in solution explorer I click and drag the required table, but get the black circle with the line through it signifying not allowed, which doesn't let me do jack with the table?? Quote My website
ashrobo Posted June 6, 2003 Posted June 6, 2003 try adding a XML Schema (NOT XML File), you should be able to drag the table over now. -ashrobo Quote
hog Posted June 6, 2003 Posted June 6, 2003 And it's a result...... Thx ashrobo, now to have a play around.... Quote My website
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.