borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB Home | News Home | Forum Home | Downloads | Register | Search | PM | Profile

Previous Topic (StringBuilder Part 1) New Topic Post Reply
AndreaVB OnLine : Articles and tutorials : Crystal Reports
Poster Resource
dcostelloe
Level: VB Guru

Registered: 11-06-2002
Posts: 74
icon 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

02-09-2002 at 01:27 AM
View Profile Send Email to User Show All Posts Visit Homepage | Add Comment
AndreaVB OnLine : Articles and tutorials : Crystal Reports
Previous Topic (StringBuilder Part 1)New Topic Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder