Quantcast
Channel: Crystal Reports
Viewing all articles
Browse latest Browse all 1507

.net 2010 app pasing data to crystal report problem

$
0
0

In a vb.net 2010 application, I am having an issue when passing data to a crystal report from an access 2013 database correctly. Sometimes the data displayed is correct and but most of the time it is off since some rows from the dataset are not passed to the report correctly. When I run the query in access 2013 to see rows from the rptReportData, the data returned is correct.

  I am wondering if I need to clear out the cache, dispose of an object, refresh the data supplied to the report?

 I am wondering if you can tell me what is wrong? Here is the code I am referring to:

Private Sub PrintYTDData()
        Dim rp As New DataSet
        Dim rpt As New rptYearToDate
        Dim oledbconkar As New OleDbConnection(DataConnect)
        Dim sWhereStatement As String

        If oledbconkar.State = ConnectionState.Closed Then oledbconkar.Open()
        strSql = ""
        strSql = "DELETE * FROM rptReportData"
        ExecuteSQL(strSql)

        strSql = ""
        strSql = "INSERT INTO rptReportData ( SchNum, Name, InvNum,InvDate, ItemNum, Description, Quantity, UnitPrice, Amount, SortID ) "
        strSql = strSql & "SELECT a.SchNum,a.Name,a.InvNum,a.InvDate,a.ItemNum,a.Description,a.Quantity,a.UnitPrice,a.Amount,"
        strSql = strSql & "IIf(a.SchNum='716','0' & a.SchNum,'1' & a.SchNum) AS SortID "
        strSql = strSql & "FROM tbl a "  

        ExecuteSQL(strSql)

        strSql = ""
        strSql = "INSERT INTO rptReportData ( SchNum, Name, InvNum,InvDate, ItemNum, Description, Quantity, UnitPrice, Amount, SortID ) "
        strSql = strSql & "SELECT a.SchNum,a.Name,a.InvNum,a.InvDate,a.ItemNum,a.Description,a.Quantity,a.UnitPrice,a.Amount,"
        strSql = strSql & "IIf(a.SchNum='716','0' & a.SchNum,'1' & a.SchNum) AS SortID "
        strSql = strSql & "FROM tblP a "
       
        ExecuteSQL(strSql)

        System.Threading.Thread.Sleep(1000)

        strSql = ""
        strSql = "SELECT SchNum,Name,ItemNum,Description,Quantity,UnitPrice,Amount,SortID "
        strSql = strSql & "FROM rptReportData "

        Dim cmd As New OleDbCommand(strSql, oledbconkar)

        da = New OleDbDataAdapter(cmd)
        dsObj.Clear()
        dsObj.MainData.Clear()
        Try
            da.Fill(dsObj, "MainData")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Exit Sub
        End Try

        rpt.SetDataSource(dsObj)    

        Me.View2.ReportSource = rpt
    End Sub


Viewing all articles
Browse latest Browse all 1507

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>