Results 1 to 6 of 6

Thread: Problem with stored procedure and crystal

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    147

    Problem with stored procedure and crystal

    Hi all - thanks to everyone who helped with my other thread...

    Decided to go down the route of the stored procedure. This works fine and I can populate a datagrid with the results.

    I created a dummy datadapter with the fields that would be produced by my stored procedure and created a dataset (dsyearlyturnover) to be filled by my stored procedure. I then created a crystal report from that dataset but I cannot seem to get any data picked up on it... the datagrid fills out fine so I know the data is there:

    VB Code:
    1. Me.DsYearlyTurnover1.Clear()
    2.         Dim orpt As New rptyearlyturnover()
    3.  
    4.         Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand("sp_invoices", SqlConnection1)
    5.  
    6.         sqlCommand.CommandType = CommandType.StoredProcedure
    7.         sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@clientid", Me.ComboBox1.SelectedValue))
    8.  
    9.         sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@datefrom", ("04/01/" & Me.ComboBox2.Text)))
    10.         sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dateto", ("03/31/" & CInt(Me.ComboBox2.Text) + 1)))
    11.         'Create a SqlDataAdapter to talk to the database
    12.         Dim da As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter()
    13.         da.SelectCommand = sqlCommand
    14.  
    15.         'Create a DataSet to hold the results
    16.         Dim ds As DataSet = New DataSet()
    17.         'Fill the Dataset
    18.         da.Fill(DsYearlyTurnover1)
    19.         orpt.SetDataSource(DsYearlyTurnover1)
    20.         Me.CrystalReportViewer1.ReportSource = orpt
    21.         SqlConnection1.Close()

    Hopefully a bit easier than my last question

    I think I must have missed out something obvious..

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    147

    Re: Problem with stored procedure and crystal

    OK how can I get a dataset I have created and populated in code to be the same as a physical dataset in the form designer which needs to be passed to crystal?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    147

    Re: Problem with stored procedure and crystal

    Please help - I have a bit of a deadline now seen as though the stored procedure part took me about 25 hours. What is my best bet? I need a strongly typed dataset for crystal but cannot fill it from code properly from my stored procedure?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    147

    Re: Problem with stored procedure and crystal

    Is there any way I can do this at all? The stored procedure produces the correct results - all I need now is to get those results into a stongly typed dataset to add on to my crystal report - I can't believe this has taken me 3 days...

  5. #5
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Problem with stored procedure and crystal

    Offhand, I don't see anything wrong. I do this in my reports as well, use ReportClass.SetDataSource(Dataset). Are you sure there's data in your Dataset? And it's the same Dataset the report is using?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    147

    Re: Problem with stored procedure and crystal

    Yeah - I think it's because my stored procedure has a temp table - I'm going to do this another way now I think...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width