Start New Discussion within our Software Development Community

I want to filter data from a billno to crystal report this the coding i used

Dim connectionstring As String = Module1.connectionString
    Dim sqlconn As New SqlConnection(connectionstring)
    Public sqlDataset As New DataSet
    Dim myCommand1 As SqlCommand
    Dim myCommand2 As SqlCommand
    Public dr As SqlDataReader
    Dim myConnection As SqlConnection
    Dim nxtmajor As Integer
    Dim sqlcmd As New SqlCommand
    'Dim dep As String
    Dim tbStudent As DataTable
    Public totalamount As Double
    Dim total As Integer

    Public productid1 As String

    Dim lCount As Integer
    Dim myCommand As SqlCommand
    Dim value As Integer
    Public Function billno_details()
        myConnection = New SqlConnection(connectionstring)
        myCommand = New SqlCommand("SELECT TOP 1 Bill_No FROM sell ORDER BY Bill_No DESC ", myConnection)
        dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        If dr.HasRows Then
            value = dr.Item("Bill_No")
        End If
        Dim da As New SqlDataAdapter(myCommand)

        Dim ds As New DataSet
        Dim dv As New DataView
        Dim dt As New DataTable
        da.Fill(ds, "sell")
        dv = New DataView(ds.Tables(0))
        dt = dv.ToTable

    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub

    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
        Dim cryRpt As New ReportDocument
        Dim value As Integer = billno_details()
        CrystalReportViewer1.SelectionFormula() = "{sell.Bill_No }='" & Trim(value) & "' "
        cryRpt.Load("G:\Sales and inventory system\CrystalReport2.rpt")
        CrystalReportViewer1.ReportSource = cryRpt
    End Sub
This article has been dead for over six months. Start a new discussion instead.