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)
        myConnection.Open()
        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
            dr.Read()
            value = dr.Item("Bill_No")
        End If
        dr.Close()
        Dim da As New SqlDataAdapter(myCommand)

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

    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide()
    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
        CrystalReportViewer1.Refresh()
    End Sub

What do you want to filter? Null billno?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.