Click here to Skip to main content
15,886,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please tell me how to load repx file in windows form application in vb.net code language... Please it's very urgent please anyone tell me..
Posted

1 solution

VB
[VB.NET]Open in popup window
    Private Sub CreateReport(ByVal ReportPath As String)

        ' Load Report
        Dim report As New DevExpress.XtraReports.UI.XtraReport()
        report.LoadLayout(ReportPath)


        ' Read Tables(names), that are needed for the .repx-File
        Dim reportDataSet As DataSet = TryCast(report.DataSource, DataSet)
        Dim newDataSet As New DataSet(reportDataSet.DataSetName)


        ' Load DataTables from current Connection
        For Each dt As DataTable In reportDataSet.Tables()
            Dim newDataTable As DataTable = LoadDataTable(dt.TableName())
            newDataSet.Tables.Add(newDataTable)
        Next


        ' Set New DataSource
        report.DataSource = newDataSet


        ' Show Report
        PrintControl1.PrintingSystem = report.PrintingSystem
        report.PrintingSystem.SetCommandVisibility(DevExpress.XtraPrinting.PrintingSystemCommand.Parameters, DevExpress.XtraPrinting.CommandVisibility.None)
        report.CreateDocument(True)

    End Sub


    Private Function LoadDataTable(ByVal tableName As String) As DataTable

        Dim cmd As New OleDb.OleDbCommand("SELECT * FROM " & tableName, conn)
        Dim dt As New DataTable(tableName)

        conn.Open()
        dt.Load(cmd.ExecuteReader)
        conn.Close()
        Return dt

    End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900