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:
Me.DsYearlyTurnover1.Clear()
Dim orpt As New rptyearlyturnover()
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand("sp_invoices", SqlConnection1)
sqlCommand.CommandType = CommandType.StoredProcedure
sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@clientid", Me.ComboBox1.SelectedValue))
sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@datefrom", ("04/01/" & Me.ComboBox2.Text)))
sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dateto", ("03/31/" & CInt(Me.ComboBox2.Text) + 1)))
'Create a SqlDataAdapter to talk to the database
Dim da As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter()
da.SelectCommand = sqlCommand
'Create a DataSet to hold the results
Dim ds As DataSet = New DataSet()
'Fill the Dataset
da.Fill(DsYearlyTurnover1)
orpt.SetDataSource(DsYearlyTurnover1)
Me.CrystalReportViewer1.ReportSource = orpt
SqlConnection1.Close()
Hopefully a bit easier than my last question :)
I think I must have missed out something obvious..
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?
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?
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... :(
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?
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...