Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Having Problem with my code for importing value to crystal report. i'm using 3 SQL queries in my Dataset file and 1 Crystal report with 3 tables link to each other.

and this is my code

VB
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New AGprint() 'The DataSet you created.
Try
    MyCommand.Connection = cn
    MyCommand.CommandText = "SELECT * FROM actualguesting where foilionum=" + mainForm.folioid
    MyCommand.CommandType = CommandType.Text
    myDA.SelectCommand = MyCommand
    myDA.Fill(myDS, "actualguesting")

    MyCommand = New SqlCommand
    myDA = New SqlDataAdapter

    MyCommand.Connection = cn
    MyCommand.CommandText = "SELECT * FROM AGtransactions where foilionum=" + mainForm.folioid
    MyCommand.CommandType = CommandType.Text
    myDA.SelectCommand = MyCommand
    myDA.Fill(myDS, "AGtransactions")
    myDS.EnforceConstraints = False




    Dim rpt As New AGprintreceiptDC() 'The report you created.
    rpt.SetDataSource(myDS)
    CrystalReportViewer1.ReportSource = rpt


My problem is .. The values is not showing on Print Previewer/report document..

Edit:


It does work when i try select 1 table only..


VB
Dim MyCommand As New SqlCommand()
      Dim myDA As New SqlDataAdapter()
      Dim myDS As New AGprint() 'The DataSet you created.
      Try
          MyCommand.Connection = cn
          MyCommand.CommandText = "SELECT * FROM actualguesting where foilionum=" + mainForm.folioid
          MyCommand.CommandType = CommandType.Text
          myDA.SelectCommand = MyCommand
          myDA.Fill(myDS, "actualguesting")
          myDS.EnforceConstraints = False
          Dim rpt As New AGprintreceiptDC() 'The report you created.
          rpt.SetDataSource(myDS)
          CrystalReportViewer1.ReportSource = rpt



And i tried using 2 dataset file for each. but values is not showing again..
Posted
Updated 11-Jul-13 16:51pm
v2
Comments
berrymaria 11-Jul-13 21:44pm    
Check this thread

http://www.codeproject.com/Questions/283546/Reporting-Report-viewer-VB-net
[no name] 11-Jul-13 21:53pm    
The first thing is that you are try to use string concatenation (use parameterized queries instead). The second thing I see is that you are using + for string concatenation when in VB you would need to use &.
Justin Jendrick Nocillado 11-Jul-13 22:19pm    
It does work when i try select 1 table only..


Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New AGprint() 'The DataSet you created.
Try
MyCommand.Connection = cn
MyCommand.CommandText = "SELECT * FROM actualguesting where foilionum=" + mainForm.folioid
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "actualguesting")
myDS.EnforceConstraints = False
Dim rpt As New AGprintreceiptDC() 'The report you created.
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
[no name] 12-Jul-13 9:03am    
Of course it does. That is all you are using anyway.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900