dcostelloe Level: VB Guru
 Registered: 11-06-2002 Posts: 74
|
Crystal Reports
Well I managed to get a Crystal Report working over the web not bad for an hours work :-)
Requires you to add a Crystal Report Viewer to a web form and create a sample report .rpt file.
How to connect a report to a SQL server Database using a stored Procedure:
Private Sub BuildReport()
Const sCommand As String = "EXEC spS_Stats"
' This is the report you generated
Dim oRpt As crActivity = New crActivity()
Dim conn As OleDbConnection = New OleDbConnection("Provider=SQLOLEDB;UserID = <UserName>; PWD=<password>;Data Source=<ServerName>;Initial Catalog=<DataBaseName>;")
Dim MyCmd As OleDbCommand = New OleDbCommand(sCommand, conn)
Dim dsReport As DataSet = New DataSet()
Dim MyAdapter As OleDbDataAdapter = New OleDbDataAdapter(sCommand, conn)
MyAdapter.Fill(dsReport, "TableName")
With oRpt
.SetDataSource(dsReport)
End With
CrystalReportViewer1.ReportSource = oRpt
MyAdapter.Dispose()
End Sub
Secret:
You can have VS.Net create the dataset file .xsd by using the following:
Select your Project File right click and select Add New from the window select DataSet and add to project, in the window of the new dataset select server explorer.
Then connect to the server available drag your stored procedure to the dataset window and there you have a dataset ready.
Be sure to Name you table to the same name as the stored procedure this is very important otherwise you get Login Error.
Example using the above:
MyAdapter.Fill(dsReport, "spS_Stats")
Walla you can now use any dataset you want and proceed through any architecture levels.
Save ya a bit off a headache
[Edited by dcostelloe on 06-09-2002 at 12:17 PM GMT]
____________________________
Life is but a merry go round
around and around :-)
Visit us today:
http://www.welford-costelloe.com
|