help with subreport

H

hodgesp

I have a c# web application. I have created a crystal report and report
view
er.

I can get the report to display by itself but when I add a subreport I
eithe
r get a logon error or object not set to an instance of an object.
I found sites that show the functions to login to a subreport but it
doesn't
seem to work.

Does anyone know a simple and straight forwatrd way to logon to a
subreport
so it will display at runtime.

The subreport is basically it's own report that displays in the header
of th
e main report. It has it's own selection criteria and is NOT linked to
the m
ain report in any way.

I also would like to know why my Export script doesn't seem to work
when I
try to use a date range. It works when I have a single sql parameter
but whe
n I try to use a dat range it freaks out.

here is my code for the report by itself and the code for the export to
pdf.


if(Session["rptSelected"].ToString() == "1") //--check which report
users wa
nts to run---//
{
this.sqlSelectCommandComparison.CommandText = "SELECT * , '" +
Session["From
Date"] + "' AS FromDt, Convert(SmallDateTime, '" + Session["ToDate"] +
"') A
S ToDt FROM qselComparison WHERE SAMPDATE BETWEEN '" +
Session["FromDate"] +
"' AND '" + Session["ToDate"] + "' Order By SAMPDATE";
this.sqlDAComparison
Fill(this.dsVocComparison1,"qselComparison"); Session["ReportName"] =
"crVo
cComparison1";
this.crVocComparison1.SetDatabaseLogon("username","password","ServerName","d
bName");
this.crVocComparison1.SetDataSource(this.dsVocComparison1);
this.crVocComparison1.PrintOptions.PaperOrientation =
PaperOrientation.Portr
ait;
this.crVocComparison1.PrintOptions.PaperSize =
CrystalDecisions.Shared.Paper
Size.DefaultPaperSize;
this.crvVOC.ReportSource = this.crVocComparison1;
}


export code

if (Session["rptSelected"].ToString() =="1") //--check which report
users wa
nts to run---//
{
crVocComparison1.SetDatabaseLogon("username","password","ServerName","dbName
",true);
crVocComparison1.RecordSelectionFormula = crvVOC.SelectionFormula;
string selectFormula;
selectFormula = "{qselComparison.SAMPDATE} >= '" +
Session["FromDate"].To
String() + "' AND {qselComparison.SAMPDATE} <= '" +
Session["ToDate"].ToS
tring() + "'" ;
crVocComparison1.DataDefinition.RecordSelectionFormula =
selectFormula;
MemoryStream oStream; // using System.IO
oStream =
(MemoryStream)this.crVocComparison1.ExportToStream(CrystalDecision
s.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
oStream.Close();
oStream = null;
}



confused confused
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top