I'm developing a small POS system using VB.Net , MS Sql and Crystal Reports. I have no trouble viewing reports using Cry Rep Viewer. But when i try to print a bill during runtime the report becomes empty. Following is the sequence i'm executing within the procedure.

Generate bill no
Deduct qty from stocks
add the transaction from temp table to final sales table
print bill
delete temp table transactions
clear for next transaction
But my problem comes during the bill printing. Bill does not pickup the necessary records from the sales table. Following is my code for the end transaction. (I am using few of my own methods and functions which are from another class and im also using a fix bill no for testing)


Code:
   Private Sub endCurrentTransaction()
    Try
        Dim sqlTempBill As String = "SELECT * FROM tb_transactions where cur_user='" & curUser & "'"
        Dim sqlSales As String = "SELECT * FROM tb_sales where bill_no=''"

        'Get Bill No
        Dim newBillNo As String = generateBillNo()

        'Deduct IT qty
        Dim tempBill As DataTable
        tempBill = myTbClass.myFunctionFetchTbData(sqlTempBill)

        Dim i As Integer = 0
        Dim curQty As Double = 0
        Dim trQty As Double = 0
        Dim updatedQty As Double = 0

        For i = 0 To tempBill.Rows.Count - 1
            curQty = 0
            'Get the Current stock qty
            Dim sqlgetCurQty As String = "SElECT cur_qty FROM tb_stock where it_batch_code='" & tempBill.Rows(i).Item("it_batch_code") & "'"

            conn.Open()
            Dim SqlCmdCurQty As New SqlCommand(sqlgetCurQty, conn)
            Dim DataReadercurQty As SqlDataReader = SqlCmdCurQty.ExecuteReader
            While DataReadercurQty.Read()
                curQty = DataReadercurQty.Item(0)
            End While
            DataReadercurQty.Close()
            conn.Close()

            trQty = tempBill.Rows(i).Item("qty")
            updatedQty = curQty - trQty
            Dim sqlUpdateQtyString As String = "UPDATE tb_stock SET cur_qty=" & Math.Round((updatedQty), 3) & " Where it_batch_code='" & tempBill.Rows(i).Item("it_batch_code") & "'"
            conn.Open()
            Dim SqlCmdQty As New SqlCommand(sqlUpdateQtyString, conn)
            SqlCmdQty.ExecuteNonQuery()
            conn.Close()

            'add to sales
            Dim tempTbSales As DataTable
            tempTbSales = myTbClass.myFunctionFetchTbData(sqlSales)
            Dim dataRow As DataRow = tempTbSales.NewRow
            dataRow("it_code") = Trim(tempBill.Rows(i).Item("it_code"))
            dataRow("it_batch_code") = Trim(tempBill.Rows(i).Item("it_batch_code"))
            dataRow("it_name") = Trim(tempBill.Rows(i).Item("it_name"))
            dataRow("buy_price") = Math.Round(tempBill.Rows(i).Item("buy_price"), 3)
            dataRow("sell_price") = Math.Round(tempBill.Rows(i).Item("sell_price"), 3)
            dataRow("qty") = Math.Round(tempBill.Rows(i).Item("qty"), 3)
            dataRow("gross_val") = Math.Round(tempBill.Rows(i).Item("gross_val"), 3)
            dataRow("discount_val") = Math.Round(tempBill.Rows(i).Item("discount_val"), 3)
            dataRow("net_val") = Math.Round(tempBill.Rows(i).Item("net_val"), 3)
            dataRow("profit_profile") = Trim(tempBill.Rows(i).Item("profit_profile"))
            dataRow("discount_profile") = Trim(tempBill.Rows(i).Item("discount_profile"))
            dataRow("cus_name") = Trim(tempBill.Rows(i).Item("cus_name"))
            dataRow("tr_type") = Trim(cmbTrans.Text)
            dataRow("cr_card_type") = Trim(cmbCardType.Text)
            dataRow("card_no") = Trim(txtCardNo.Text)
            dataRow("bill_no") = newBillNo
            dataRow("discount_profile") = Trim(tempBill.Rows(i).Item("cus_name"))
            dataRow("cur_user") = curUser
            dataRow("added_date") = curServerDateTime
            tempTbSales.Rows.Add(dataRow)
            Call myTbClass.MyMethodUpdateTable(sqlSales, tempTbSales)
        Next

        i = 0

    'Print bill
    Dim cash, balance As Double
    Dim crepBill As New repBill
    crepBill.SetDatabaseLogon("sa", dbPwd)
    cash = Val(Me.txtCash.Text)
    balance = Val(Me.txtBalance.Text)

    crepBill.RecordSelectionFormula = "{TB_SALES.bill_no} ='" & "000015" & "'"
    crepBill.DataDefinition.FormulaFields("txtCash").Text = Format(cash, "#0.00")
    crepBill.DataDefinition.FormulaFields("txtBal").Text = Format(balance, "#0.00")

    crepBill.PrintToPrinter(1, False, 0, 0)
    crepBill.Dispose()

    'delete temp bill table
    For i = 0 To tempBill.Rows.Count - 1
        tempBill.Rows(i).Delete()
    Next
    Call myTbClass.MyMethodUpdateTable(sqlTempBill, tempBill)

    'reset front end
    Call loadBill()
    Call clearCurrentTransaction()
    Call clearCurrentSubTotals()
    Call clearCurCashBalance()

    'Íncrease the bill no by 1
    Call increaseBillNo()

    txtItCode.Focus()
    Catch ex As Exception
    MsgBox("This error was generated at endCurrentTransaction()")
    End Try
End Sub
enter image description here