borderAndreaVB free resources for Visual Basic developersborder

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

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Combo and Text Box)Next Topic (FORUM NOKIA TWITTER CONTEST) New Topic New Poll Post Reply
AndreaVB Forum : Database : Filtering Crystal report Display Record
Poster Message
vbLearner
Level: Big Cheese

Registered: 21-04-2006
Posts: 22

Ads by Lake Quincy Media
icon Filtering Crystal report Display Record

Hello guys,

I'm programming in vb.net 2005 and sql server 2005  and using crystal report package in it, i tried to generate a report with a filtered record but seems not working properly.

whats wrong  with this.. i already created the script in sql but still when previewing the report generated doesn't filter the records in where statement in sql query..



        Dim CrTables As Tables
        Dim CrTable As Table
        Dim TableCounter



        'Code to configure the database settings
        'Change the server="your server name where your sql server is running"
        'database="Default" database "pubs" and sql "userid" and the "password"

        Dim strConnection As String = MyconnectionStringA_SQLNet()

        Dim Connection As New SqlConnection(strConnection)

dim vstrsql as string

vstrSql="SELECT TableCustomer.Customer, TableCustomer.Address, TableCustomer.ContactNo, TableSales.ItemNo, TableSales.ProdDescription, TableSales.Qty, TableTrans.ReceiptDate, TableTrans.ReceiptTime, TableTrans.Cashier FROM   (TableTrans TableTrans INNER JOIN TableSales TableSales ON TableTrans.ReceiptNo=TableSales.ReceiptNo) LEFT OUTER JOIN TableCustomer TableCustomer ON TableTrans.Customer=TableCustomer.CustNo where TableTrans.ReceiptNo='100001'


        Dim DA As New SqlDataAdapter(VstrSql, Connection)
        Dim DS As New DataSet

        ' Create a datatable in your dataset. The datatable's name
        DA.Fill(DS)
        'Pass the reportname to string variable

        'Get the Report Location

        Dim strReportPath As String = Application.StartupPath & "\" & strReportName & ".rpt"
        'Check file exists


        If Not IO.File.Exists(strReportPath) Then
            Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
        End If
        'Assign the datasource and set the properties for Report viewer

        Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        rptDocument.Load(strReportPath)
        'This code works for both user tables and stored
        'procedures. Set the CrTables to the Tables collection
        'of the report

        CrTables = rptDocument.Database.Tables

        'Loop through each table in the report and apply the
        'LogonInfo information



        rptDocument.SetDataSource(DS.Tables(0))
        rptviewer.ShowRefreshButton = False
        rptviewer.ShowCloseButton = False
        rptviewer.ShowGroupTreeButton = False
        rptviewer.ReportSource = rptDocument
        rptviewer.Refresh()

Please help guys.. the filtering of my sql query didn't work .. how to do this please please

thanks in advance

vblearner

[Edited by vbLearner on 24-02-2010 at 04:33 PM GMT]

24-02-2010 at 05:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Filtering Crystal report Display Record
Previous Topic (Combo and Text Box)Next Topic (FORUM NOKIA TWITTER CONTEST) New Topic New Poll 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-2010 Andrea Tincaniborder