Skip to main content
Windward

Passing .net parameters example

Overview

Here is an example on how to pass the .net engine parameters.

Resolution

The comments will guide you through it. The template we use for this example is attached.

static void Main(string[] args)
{
FileStream rtf = new FileStream("Variable Invoice Sample - Template.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
FileStream output = new FileStream("test.pdf", FileMode.Create, FileAccess.Write, FileShare.None);

//Northwind datasource
String strConn = "Data Source=mssql.windwardreports.com;Initial Catalog=Northwind;User ID=demo;Password=demo;";
IReportDataSource data = new AdoDataSourceImpl("System.Data.SqlClient", strConn);

// Create a report process
Report report = new ReportPdf(rtf, output);
// run the report process
report.ProcessSetup();

//This is where we pass in the parameters
KeyPairDictionary map = new KeyPairDictionary();
//order is our variable
map.Add("order", 10537);

//This is the function where we actually tell our report the parameter values
data.Map = map;


report.ProcessData(data,"");
report.ProcessComplete();
}

 

C#

// How to Declare a KeyPairDictionary Object

 Dictionary<string, object> map = new Dictionary<string, object>();

Visual Basic .NET

// How to Declare a KeyPairDictionary Object

Dictionary(Of String, Object) map = new Dictionary(Of String, Object);

  • Was this article helpful?