Hi there,
Using VBNET2008, Crystal Report 9, SQL SERVER 2000, Northwind database for application purposes.
The CrystalReportIn voice.RPT was embedded onto VBNET2008 FORM via CrystalReportVi ewer1 whose datasource was not connected to table or dataset.
As requested by Team Leader, 3 Crystal Report TEXT OBJECT were inserted in the Crystal Report SECTION DETAILS which are filled with data using DATA READER which consist of 7 rows of data but only one row was display because the DATAREADER Row override the row before it becaues no NEW LINE was created .
Here are the coding
Using VBNET2008, Crystal Report 9, SQL SERVER 2000, Northwind database for application purposes.
The CrystalReportIn voice.RPT was embedded onto VBNET2008 FORM via CrystalReportVi ewer1 whose datasource was not connected to table or dataset.
As requested by Team Leader, 3 Crystal Report TEXT OBJECT were inserted in the Crystal Report SECTION DETAILS which are filled with data using DATA READER which consist of 7 rows of data but only one row was display because the DATAREADER Row override the row before it becaues no NEW LINE was created .
Here are the coding
Code:
Private Sub btnShowReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowReport.Click
Dim strSql As String = Nothing
strSql &= "Select OrderID, OrderDate, ProductName"
strSql &= " From Invoices "
strSql &= " Where CustomerId = '" & txtcustId.text & "' "
sqlConn = New SqlConnection(connStr)
sqlCmd = New SqlCommand(strSql, sqlConn)
sqlConn.Open()
sqlDR = sqlCmd.ExecuteReader
' ---- setup crystal Report option and TEXT Pbject defination ---- '
Dim objRpt As New CrystalOrderInvoice
Dim cryTextObject As TextObject = Nothing
[B] Dim FmulaNewLine As FormulaFieldDefinition = Nothing[/B]
Dim cryFolder As String = "H:\VBNet2008[LEFT][/LEFT]CrystalReportApps\CrystalOrderInvoice.rpt"
objRpt.Load(cryFolder)
Me.CrystalReportViewer1.ReportSource = objRpt
Me.CrystalReportViewer1.Visible = True
While sqlDR.Read
' --- OrderID
cryTextObject = objRpt.ReportDefinition.ReportObjects("ctxtOrderId")
cryTextObject.Text = sqlDR("OrderID")
' --- OrderDate
cryTextObject = objRpt.ReportDefinition.ReportObjects("cTxtOrderDate")
cryTextObject.Text = sqlDR("OrderDate")
' --- productname
cryTextObject = objRpt.ReportDefinition.ReportObjects("cTxtProduct")
cryTextObject.Text = sqlDR("ProductName")
' --- new line
[B] FmulaNewLine = objRpt.DataDefinition.FormulaFields("FmulaNewLine")
FmulaNewLine.Text = Chr(10) & Chr(13) [/B]
End While
sqlconn.Close
End Sub
Private Sub btnShowReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowReport.Click
Dim strSql As String = Nothing
strSql &= "Select OrderID, OrderDate, ProductName"
strSql &= " From Invoices "
strSql &= " Where CustomerId = '" & txtcustId.text & "' "
sqlConn = New SqlConnection(connStr)
sqlCmd = New SqlCommand(strSql, sqlConn)
sqlConn.Open()
sqlDR = sqlCmd.ExecuteReader
' ---- setup crystal Report option and TEXT Pbject defination ---- '
Dim objRpt As New CrystalOrderInvoice
Dim cryTextObject As TextObject = Nothing
Dim FmulaNewLine As FormulaFieldDefinition = Nothing
Dim cryFolder As String = "H:\VBNet2008CrystalReportApps\CrystalOrderInvoice.rpt"
objRpt.Load(cryFolder)
Me.CrystalReportViewer1.ReportSource = objRpt
Me.CrystalReportViewer1.Visible = True
While sqlDR.Read
' --- OrderID
cryTextObject = objRpt.ReportDefinition.ReportObjects("ctxtOrderId")
cryTextObject.Text = sqlDR("OrderID")
' --- OrderDate
cryTextObject = objRpt.ReportDefinition.ReportObjects("cTxtOrderDate")
cryTextObject.Text = sqlDR("OrderDate")
' --- productname
cryTextObject = objRpt.ReportDefinition.ReportObjects("cTxtProduct")
cryTextObject.Text = sqlDR("ProductName")
' --- new line
FmulaNewLine = objRpt.DataDefinition.FormulaFields("FmulaNewLine")
FmulaNewLine.Text = Chr(10) & Chr(13)
End While
sqlconn.Close
End Sub
Comment