Print Page | Close Window

Data connection from code

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6093
Printed Date: 27 Apr 2024 at 12:57pm


Topic: Data connection from code
Posted By: cowboy the duck
Subject: Data connection from code
Date Posted: 15 Apr 2009 at 2:02pm
I have built a web app in VS.net 2008 and in VB.net.  It is to genereate a CR from a sql db based on the selection of user on webpage.  My app dynamically creates a table in sql that is to be the datasource for the CR.
 
The app pushes the contents of this table into a dataset/datatable dynamically.  That works great.  My problem is I cannot figure out how to have my code connect to this dataset once it is created.
 
I have created the dataset in my project as an xsd file with all the correct fields.  The program removes the records and re-populates this table at run time.  i wonder if the fact that the program remove the data from the sql table at runtime causes the connection to not happen.
 
This is the code for the last attempt that I tried;
 

finalsql = "SELECT * from dbo.tblStudentVerify"

Dim myadapter As New SqlDataAdapter(finalsql, myconn)

Dim myDS As New DataSet()

myDS.Tables.Add("tblStudentVerify")

myadapter.Fill(myDS, "tblStudentVerify")

Dim myRpt As New ReportDocument

myRpt.Load("C:\\inetpub\\wwwroot\\StudentVerification\\Student_Verify\\CrystalReport.rpt")

myRpt.SetDataSource("StudentVerifyDataSet_tblStudentVerify")

CrystalReportViewer.DisplayGroupTree = False

CrystalReportViewer.Visible = True

CrystalReportViewer.ReportSource = myRpt

CrystalReportViewer.DataBind()

CrystalReportViewer.RefreshReport()

Please help!  Thanks!
 
 


-------------
John Mitchell



Print Page | Close Window