|
I guess I'm missing something big here.
I'm used to data grids where you just give it the source and it populates it.
Another person made a CrystalReport.rpt file for me to use as a template, that's what I load.
Then I have a stored procedure that fills the datatable you see in the code.
I didn't know I needed to make a template to pass to the .rpt template.
How is something like this done?
|
|
|
|
|
partt wrote:
I didn't know I needed to make a template to pass to the .rpt template
if someone already made you a template file, what did they use to define the data definition of that template? that's the key... the underlying datasource (your dataset) needs to match the datadefinition of the report template file.
you have 9/10's of the work done really. here's basically step for step what you need to do. from the beginning:
1. decide on your data structure. whatever suits your needs for what you need to display to your user should do.
2. create the dataset either through code or through the xml designer in the vs.net ide.
3. either way you need to end up with a valid .xsd file.
(if you create your dataset through code then just step through the code to the point where it's populated and use the command window to perform a myDataset.WriteXml("outputfile.xsd", xmlwritemode.writeschema)) this will give you a file that you can then use to set the datadefinion of your cr template file.
4. Create a new crystal report template (or just open up the one that you already have) and set the datasource for the template = you newly generated .xsd file.
5. Create your report by dragging and dropping fields from your datasource onto the designer.
6. basically do what you did in your code above to load this report template into a reportdocument object and set the datasource = your dataset.
it's really not complicated. the most important thing is to make sure that the data structure that you are passing into the reportdocument object as the datasource matches what is defined in the report template.
if you have to make some changes to the datasource to add or remove a field, make sure you re-load the data structure back into the report template by right clicking the datasource node in the field explorer and clicking verify database. if they are off slightly you'll get some really generic errors such as 'report load failed', or 'query engine error'. such is life with crystal.
i hope this explains the process a little more clearly. if not you know where to find me...
-jim
|
|
|
|
|
I talked to the person who made the .rpt file.
They told CrystalReports to expect data from the stored procedure I use and they clicked and dragged the field names onto the crystal report sheet from crystal reports' view of that stored procedure.
Not sure how clear that was....
|
|
|
|
|
yep. perfectly clear. if that's the case, then i believe all you have to do is display the report. once you do that the report should connect to the sproc automatically and pull the data appropriately. i think what you were doing before to keep this from happening was setting the data source. skip this part and let me know if this doesn't work.
if your report and/or the stored procedure requires any parameters then you'll need to supply those via code. this isn't that difficult to figure out though.
another good source for crystal stuff is brian bischoff's free ebook. it's an abridged version of a book he's since had published regarding crystal reports and .net. it requires registration though.
anyways, hope this works out for you.
-jim
|
|
|
|
|
I tried this but it gives me an error: "Invalid Field Name"
Dim crReportDocument As ReportDocument
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim Fname As String
crReportDocument = New ReportDocument()
crReportDocument.Load("destination to .rpt")
Dim logonInfo As New TableLogOnInfo()
Dim i As Integer
For i = 0 To crReportDocument.Database.Tables.Count - 1
logonInfo.ConnectionInfo.ServerName = "servername"
logonInfo.ConnectionInfo.DatabaseName = "DBname"
logonInfo.ConnectionInfo.UserID = "userID"
logonInfo.ConnectionInfo.Password = "passWord"
crReportDocument.Database.Tables.Item(i).ApplyLogOnInfo(logonInfo)
Next
Dim discreteParam As New ParameterDiscreteValue()
Dim paramField As ParameterFieldDefinition
Dim defaultValue As ParameterValues
paramField = crReportDocument.DataDefinition.ParameterFields.Item("SexID")
discreteParam.Value = txtGender.Text.Trim
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
paramField = crReportDocument.DataDefinition.ParameterFields.Item("RaceID")
discreteParam.Value = txtRace.Text.Trim
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
paramField = crReportDocument.DataDefinition.ParameterFields.Item("LBirth")
discreteParam.Value = lblUpDOB.Text
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
paramField = crReportDocument.DataDefinition.ParameterFields.Item("UBirth")
discreteParam.Value = lblLowDOB.Text
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
paramField = crReportDocument.DataDefinition.ParameterFields.Item("SiteID")
discreteParam.Value = ddlSite.SelectedItem.Value
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
Dim tDay As Integer
Dim tCall As Integer
Dim DD As DateTime 'Date that is X amount of days in the past decided by txtPast
Dim CallActivity As DateTime 'date that is x amount of days in past txtCall, for Call Activity
tDay = Integer.Parse(txtPast.Text)
tCall = Integer.Parse(txtCall.Text)
DD = Today.AddDays(-tDay)
CallActivity = Today.AddDays(-tCall)
paramField = crReportDocument.DataDefinition.ParameterFields.Item("DD")
discreteParam.Value = DD
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
paramField = crReportDocument.DataDefinition.ParameterFields.Item("CallActivity")
discreteParam.Value = CallActivity
defaultValue = paramField.DefaultValues
defaultValue.Add(discreteParam)
paramField.ApplyCurrentValues(defaultValue)
Dim N As String
N = "CallSheets" & ddlSite.SelectedItem.Text & Now & ".PDF"
N = Replace(N, Chr(32), "")
N = Replace(N, ":", "")
N = Replace(N, "/", "")
N = Replace(N, ",", "")
Fname = "destination path" & N
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crReportDocument.Export()
|
|
|
|
|
Hello,
I am pretty much new to the .Net community. I read the article abt credit card validation by Paul Ingle. It was awesome. I just have a few questions though. When you r developing this application, do u create it as a windows application and go ahead and design the forms or as something else? Might sound as a basic question for you but i am still learning.
I would really appreciate any help to kind of give an insight to this whole .net thing
thanks a lot...;)
|
|
|
|
|
You should ask in the forum attached to the article - it's at the bottom of the page.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
eHi,
I have written an application and want to launch it straight after install automatically. I can get it to launch but install still runs in the background until the app is closed and install then finishes.
I am using a Custom Action at commit to do this.
I also tried using
cmd = Session.Property("CustomAction")
Set wsh = CreateObject("WScript.Shell")
wsh.Run cmd, 7, False
where CustomAction is the name of my app. I put this in as a Custom Action but this would not work at all. It would not execute the script.
Any help would be much appreciated
|
|
|
|
|
This is what I use, except I start the program, not IE.
Visual Studio
Walkthrough: Creating a Custom Action
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxwlkwalkthroughcreatingcustomaction.asp
|
|
|
|
|
Hi,
That will still run the application before install exits, wont it? I tried it and it gave me an error. Im using the same technique to get the user to enter information before the app installs.
I didnt follow your second post.sorry.
Any ideas why it wont work?
Thanks in advacnce
Steve69
|
|
|
|
|
By the way steve,
Here's another little trick,
If you deploy the launcher you made into the temp folder, the next time the user cleans the temp folder it will be deleted.
|
|
|
|
|
How to setting datagrid properties to retieve data from MSSQL database?
|
|
|
|
|
|
i have seen the code.but it is for asp..Actually i'm using VB6.0 connected with MSSQL Database server.How to set up data grid control and retrieve data from the database.thank you.
|
|
|
|
|
|
Hey,
Using the FolderBrowserDialog i select a folder. From here i want to recurse through this folder and add it (and all its subfolders and files) to an XML file so it can then populate a treeeview.
I am having trouble recursing the Folders and files in to the correct xml nodes during the recursion.
I am using structure:
<category>
<name></name>
<file>
<name></name>
<path></path>
</file>
</category>
And for Sub Folders
<category>
<name></name>
<file>
<name></name>
<path></path>
</file>
<category>
<name></name>
<file>
<name></name>
<path></path>
</file>
</category>
</category>
Any help or tip or links would be very helpful
thanks for your time
Chris
|
|
|
|
|
hi, This is a particularly easy problem to solve as a small recursive function will do all the work for you.
The best way I could think to do this was to derive a class from XmlTextWriter - in my case I named it XmlFileSystemWriter. The purpose here is to add a method that will write out a directory recursively, to the Xml, in the format you want.
Here's what I ended up with:
using System;
using System.IO;
using System.Xml;
using System.Text;
namespace TestApp
{
public class XmlFileSystemWriter : XmlTextWriter
{
public XmlFileSystemWriter(TextWriter w) : base(w)
{
}
public XmlFileSystemWriter(string fileName, Encoding encoding) : base(fileName, encoding)
{
}
public XmlFileSystemWriter(Stream stream, Encoding encoding) : base(stream, encoding)
{
}
public void WriteFileSystemInfo(DirectoryInfo baseDir)
{
this.WriteStartElement("fileSystemInfo");
this.WriteDirectory(baseDir);
this.WriteEndElement();
}
private void WriteFile(FileInfo info)
{
this.WriteStartElement("file");
this.WriteElementString("name",info.Name);
this.WriteElementString("path",info.FullName);
this.WriteEndElement();
}
private void WriteDirectory(DirectoryInfo info)
{
this.WriteStartElement("category");
this.WriteElementString("name",info.Name);
foreach(DirectoryInfo subDir in info.GetDirectories())
WriteDirectory(subDir);
foreach(FileInfo file in info.GetFiles())
WriteFile(file);
this.WriteEndElement();
}
}
}
Usage should be simple enough to work out:
<br />
DirectoryInfo di = new DirectoryInfo("C:\\yourdirectory");<br />
XmlFileSystemWriter w = new XmlFileSystemWriter(Console.Out);
w.Formatting = Formatting.Indent;<br />
w.WriteFileSystemInfo(di);<br />
I have provided all three constructors for you so you can use a TextWriter, write to a specified file, or to a specified Stream - have a play with the above and post back if you have any problems.
|
|
|
|
|
Hey Jamie,
Your help proved real usefull, I have got it working writing dir structure to xml. I changed my schema though to:
<category label="Directory Name">
<file>
<name>Test1</name>
<path>C:\Test1</path>
<file>
<category label="Sub Category">
<file>
<name>Test2</name>
<path>C:\Test2</path>
<file>
</category>
</category>
The only problems i seem to be having now is recursing through the XML document to add nodes to tree view so the category attributes are the Parent and child tree nodes and the <file> <name> information is the files within either nodes.
So for example from the above XML
Directory Name
- Sub Category
- Test2
- Test1
Any help would also be appreciated on this matter, thanks very much for your effort so far.
Kind regards
Chris
|
|
|
|
|
Solved my problem, thanks for the help
chris
|
|
|
|
|
Hi All,
I am abt to trying filling PDF forms using VB.NET in DOT NET.
Would you please anybody let me know Saving ,Deleting ,Editing PDF forms in DOT NET if anybody has contributed on this.Please send me ur suggestion ASAP
Regards
Anurag
Anurag
|
|
|
|
|
There are a number of components you can buy in to do this, some of the vendors even advertise on CodeProject, so it shouldn't be too hard to search for things to do this.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Can you get something deep besides this...Getting Components from third party and build ur own...
Regards
Anurag
|
|
|
|
|
|
But if you wanted to build your own, the documentation and SDK's to support what you want to do can be found at http://developer.adobe.com, for the nominal fee of $195.00 US, of course. Other than that, you'll have to search the Open Source sites, like SourceForge, for similar projects.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I want to develop one application in VB.NET (ASP.NET Web Application). Now I want to use some of the functions which are in my DLL that I developed in C++.
Plz any one can guid me how to include the DLL or what is the code to include DLL into VB.NET ?
Pls help me dear ?
Regards
Mike
|
|
|
|