Click here to Skip to main content
15,908,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to print multiple student fee voucher record on single click.
that code which im going to share with you with the help of that code i can only print single student fee voucher but i want to print all fee voucher which is present in given sql table.

What I have tried:

VB
<pre>Public Class Employe_Led_report

    Public Function itemQillareport() As DataSet
        Dim dsData As DataSet
        Try

                   dsData = DalHelper.ExecuteDataset(m_ConString, CommandType.Text, "SELECT dbo.PrintChallan.*, dbo.School_Info.* FROM dbo.PrintChallan CROSS JOIN dbo.School_Info where PrintChallan.Reg_num='" & StidentFee.TextBox14.Text & "' and PrintChallan.Received_Amount='0'  and PrintChallan.Fea_year='" & StidentFee.TextBox4.Text & "' and School_Info.Id='1'")
        Catch ex As Exception
            Return Nothing
        End Try
        Return dsData

    End Function
    

    Private Sub Employe_Led_report_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
       

        ReportViewer1.LocalReport.ReportEmbeddedResource = "KTC.Report36.rdlc"
            Dim rdsNumberofReferrals As New Microsoft.Reporting.WinForms.ReportDataSource()

            rdsNumberofReferrals.Name = "DataSet1"
            Dim dsBrands As DataSet = itemQillareport()
            rdsNumberofReferrals.Value = dsBrands.Tables(0)
            ReportViewer1.LocalReport.DataSources.Add(rdsNumberofReferrals)
            ReportViewer1.Update()
        Dim newPageSettings As New System.Drawing.Printing.PageSettings
        newPageSettings.PaperSize = New Printing.PaperSize("Custom", 820, 1150)

        newPageSettings.Landscape = True
        newPageSettings.Margins = New System.Drawing.Printing.Margins(30, 10, 10, 10)
        ReportViewer1.SetPageSettings(newPageSettings)

        Me.ReportViewer1.ZoomPercent = 90
        Me.ReportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent
        Me.ReportViewer1.RefreshReport()

    End Sub

   
End Class
Posted
Updated 8-Jun-19 23:09pm
Comments
Dave Kreskowiak 9-Jun-19 10:50am    
REPOST - https://www.codeproject.com/Questions/5061521/I-want-to-export-all-student-fee-voucher-in-one-PD

1 solution

Don't do it like that! Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.

When you concatenate strings, you cause problems because SQL receives commands like:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'
Which SQL sees as three separate commands:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
SQL
DROP TABLE MyTable;
A perfectly valid "delete the table" command
SQL
--'
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.

So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?

When you have fixed that throughout your app, you can move on - but until then, your DB is at too much risk to continue.
 
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