Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using following code to load result of a sql stored porcedure. I dont know why it is not showing the contents.It shows only the heading..
my code is as follows,
VB
Dim reportDocument As New ReportDocument
        Dim paramField = New ParameterField
        Dim paramFields = New ParameterFields
        Dim paramDiscreteValue = New ParameterDiscreteValue

        paramField.Name = "@Name"
     
        paramDiscreteValue.Value = cbaccount.ValueMember
        paramField.CurrentValues.Add(paramDiscreteValue)
        'Add the paramField to paramFields
        paramFields.Add(paramField)

     
        paramField = New ParameterField()
        paramField.Name = "@SD"
        paramDiscreteValue = New ParameterDiscreteValue
        paramDiscreteValue.Value = DTP1.Value
        paramField.CurrentValues.Add(paramDiscreteValue)

        'Add the paramField to paramFields
        paramFields.Add(paramField)

       
        paramField = New ParameterField()
        paramField.Name = "@ED"
        paramDiscreteValue = New ParameterDiscreteValue
        paramDiscreteValue.Value = DTP2.Value
        paramField.CurrentValues.Add(paramDiscreteValue)
        'Add the paramField to paramFields
        paramFields.Add(paramField)
        CrystalReportViewer1.ParameterFieldInfo = paramFields

        reportDocument.Load("C:\Users\User\Documents\Visual Studio 2005\Projects\Alisoftpremium\Alisoftpremium\CrystalReport1.rpt")



        'Load the report by setting the report source
        CrystalReportViewer1.ReportSource = reportDocument
Posted
Comments
Suvendu Shekhar Giri 29-Sep-15 5:04am    
Make sure that data exists in database for the applied filters.
Member 11749706 29-Sep-15 5:30am    
yes..

i changed @name to
paramDiscreteValue.Value = cbaccount.text

i am getting result in my database but not in crystal report..


exec spLegderNameDt 'Emichem','09/01/2015','09/29/2015'

do i need to configure anything else?? I am getting only blank page with headings in crystal report
sreeyush sudhakaran 29-Sep-15 6:57am    
Is data is fetched using a stored procedure in Crystal reports then change in Date Format may cause problem.
Member 11749706 29-Sep-15 7:46am    
my total code is as follows,


Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Configuration
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared


Public Class ledger
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("DCS").ConnectionString)
Dim ds As New DataSet

Private Sub ledger_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

con.Open()


Dim cmd As String = "select ACID,Account from vact"
Dim da1 As New SqlDataAdapter(cmd, con)
da1.Fill(ds, "vact")
cbaccount.DataSource = ds.Tables("vact")
cbaccount.DisplayMember = "Account"

cbaccount.ValueMember = "Account"



DTP1.Format = DateTimePickerFormat.Custom
DTP1.CustomFormat = "MM/dd/yyyy"
DTP2.Format = DateTimePickerFormat.Custom
DTP2.CustomFormat = "MM/dd/yyyy"

con.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim reportDocument As New ReportDocument
Dim paramField = New ParameterField
Dim paramFields = New ParameterFields
Dim paramDiscreteValue = New ParameterDiscreteValue

'Set instances for input parameter 1-@name

paramField.Name = "@Name"

paramDiscreteValue.Value = cbaccount.Text
paramField.CurrentValues.Add(paramDiscreteValue)
'Add the paramField to paramFields
paramFields.Add(paramField)

'Set instances for input parameter 2 - @sd

paramField = New ParameterField()
paramField.Name = "@SD"
paramDiscreteValue = New ParameterDiscreteValue
paramDiscreteValue.Value = DTP1.Value
paramField.CurrentValues.Add(paramDiscreteValue)

'Add the paramField to paramFields
paramFields.Add(paramField)

'Set instances for input parameter 2 - @ED

paramField = New ParameterField()
paramField.Name = "@ED"
paramDiscreteValue = New ParameterDiscreteValue
paramDiscreteValue.Value = DTP2.Value
paramField.CurrentValues.Add(paramDiscreteValue)
'Add the paramField to paramFields
paramFields.Add(paramField)
CrystalReportViewer1.ParameterFieldInfo = paramFields

reportDocument.Load("C:\Users\User\Documents\Visual Studio 2005\Projects\Alisoftpremium\Alisoftpremium\CrystalReport1.rpt")



'Load the report by setting the report source
CrystalReportViewer1.ReportSource = reportDocument

End Sub
End Class

my sp as follows

@Name nvarchar (50),
@SD as date,
@ED as date
as
begin
select VNo,convert(nvarchar(15), Date,106)as Date, CreditAccount as Account, AmountDr as Amount,convert(nvarchar(15), DueDate,106)as [Due Date],Remarks from vTotalTrans where Debitaccount = @Name and Date between @SD and @ED
union all
select VNo,convert(nvarchar(15), Date,106)as Date, DebitAccount as Account, AmountCr as Amount,convert(nvarchar(15), DueDate,106)as [Due Date],Remarks from vTotalTrans where CreditAccount = @Name and Date between @SD and @ED
order by date

1 solution

Hi
First make sure that all the columns are present in the dataset or not in the crystal repot(.rpt) file , if not create the dataset that should contain all the columns with datatypes same as in sp returning column names..
 
Share this answer
 
v2
Comments
Richard Deeming 29-Sep-15 9:53am    
DON'T SHOUT!

Typing in all capitals on the internet is considered extremely rude.
sateesh kumar nemalikanti 30-Sep-15 1:35am    
sorry i am beginner in blogs and i will improve. thanks for letting me know

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