I've created a crystal report in crystal.net that uses a datasource of
a dataset. I am able to call this report from vbscript code inside of
asp.net and produce dynamic (fresh) data on the web! It works great.
Problem is, creating the report with a dataset in crystal.net requires
opening up visual studio and adding a dataset item to the project.
I'd like to create the report sourcing to a field defintion file (ttx)
and produce dynamic data from with that same asp.net asp.net/vbscript
code.
And actually, I'd like to produce the report in crystal 8.5 (not net).
I am currently unable to get both .net and 8.5 to produce data with
TTX.
Below is the code that does work with a crystal.net report that was
datasources with visual studio dataset. Note that I am able to
seperate the report from the project directory and away from all the
other project files so that's not why it dataset works.
My Question, how do I make this same code work with TTX data sourced
report? Right now I get the report, but no data. I've made sure the
the location of the ttx file matches that of the server and that the
ttx matches the dataset. I know I'm missing something.
=== the code:
<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
Assembly="CrystalDecisions.Web, Version=9.1.3300.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304" %>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="CrystalDecisions.CrystalReports.Engine" %>
<%@ Import Namespace ="CrystalDecisions.Shared" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer
dt = New DataTable
dt.Columns.Add(New DataColumn("n1", GetType(String)))
dt.Columns.Add(New DataColumn("n2", GetType(String)))
dt.Columns.Add(New DataColumn("n3", GetType(String)))
dt.Columns.Add(New DataColumn("n4", GetType(String)))
dt.Columns.Add(New DataColumn("n5", GetType(String)))
dt.Columns.Add(New DataColumn("n6", GetType(String)))
dim newrow as datarow
for i = 1 to 100
newrow = dt.newrow()
newrow(0) = i.tostring
newrow(1) = i.tostring
newrow(2) = i.tostring
newrow(3) = i.tostring
newrow(4) = i.tostring
newrow(5) = i.tostring
dt.rows.add(newrow)
next
MyDataGrid.DataSource = New DataView(dt)
MyDataGrid.DataBind
Dim ds As New DataSet()
ds.Tables.Add(dt)
Dim cr As ReportDocument
cr = New ReportDocument()
cr.Load("D:\jcp\aspx\w20_b\lottoc.rpt")
cr.refresh()
cr.setDataSource(ds)
CrystalReportViewer1.ReportSource = cr
End Sub
</script>
<body>
Data Grid Demo
<ASP:DataGrid id="MyDataGrid" runat="server"
BorderColor="black"
Border="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#FFFCC0"
/>
<form id="Form1" method="post" runat="server">
<CR:CrystalReportViewer id=CrystalReportViewer1 style="Z-INDEX: 101;
LEFT: 163px;
POSITION: absolute; TOP: 111px" runat="server" Width="1030px"
Height="1077px"
runat="server">
</CR:CrystalReportViewer>
</form>
</body>
</html>
=====code end |