Use Procedures

Stimulsoft Reports.NET discussion
Post Reply
ramond
Posts: 5
Joined: Thu Jun 19, 2008 11:33 am

Use Procedures

Post by ramond »

Hi,

I want to use procedure in a report but with himself not to understand like using it. That I am making bad.


Dim cnnSQL As New SqlConnection(StrCnnSrv("GPMMNET"))
Dim dsReport As New DataSet
Dim tbReport As New DataTable
Dim cmdReport As New SqlCommand("RebutsSelIdRebut", cnnSQL)
cmdReport.CommandType = CommandType.StoredProcedure
cmdReport.Parameters.Add("@vREBUT_ID", SqlDbType.BigInt).Value = LlistaRebuts.ActiveItem.Key
Dim daReport As New SqlDataAdapter
daReport.SelectCommand = cmdReport
daReport.Fill(dsReport, "TREBUTS")
cnnSQL.Open()
Try
cmdReport.ExecuteNonQuery()
tbReport = dsReport.Tables("TREBUTS")
If tbReport.Rows.Count > 0 Then

Dim ReportRebut As StiReport = New StiReport
ReportRebut.Load(Application.StartupPath & "\\Reports\rptRebutId.mrt")
ReportRebut.Compile()
ReportRebut.Dictionary.Databases.Clear()
ReportRebut.Dictionary.DataStore.Clear()
ReportRebut.CompiledReport.DataStore.Clear()
Dim dbReport As Stimulsoft.Report.Dictionary.StiSqlDatabase = TryCast(ReportRebut.Dictionary.Databases("GPMMNET"), Stimulsoft.Report.Dictionary.StiSqlDatabase)
If dbReport IsNot Nothing Then
dbReport.ConnectionString = StrCnnSrv("GPMMNET")
End If

ReportRebut.Dictionary.Databases.Add(New StiSqlDatabase("conRpt", StrCnnSrv("GPMMNET")))

ReportRebut.RegData("dsRpt", tbReport)
ReportRebut.Dictionary.Synchronize()
ReportRebut.Dictionary.DataSources(0).Name = "dsRpt"
ReportRebut.Dictionary.DataSources(0).Alias = "dsRpt"
ReportRebut.Render()
ReportRebut.Show()
End If

End If
Catch ex As SqlException
MessageBox.Show("Error: " & ex.ErrorCode, varNomAplicacio, MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message, varNomAplicacio , MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
cnnSQL.Close()
dsReport.Dispose()
daReport.Dispose()
tbReport.Dispose()
cmdReport.Dispose()
End Try

Tank You.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Use Procedures

Post by Edward »

Hello.

Please change your code as follows:

Code: Select all

If tbReport.Rows.Count > 0 Then
    Dim ReportRebut As StiReport = New StiReport
    ReportRebut.Load(Application.StartupPath & "\\Reports\rptRebutId.mrt")
    ReportRebut.Dictionary.Databases.Clear()
    ReportRebut.Dictionary.DataStore.Clear()
    ReportRebut.Compile()
    ReportRebut.RegData("dsRpt", "dsRpt", tbReport)
    ReportRebut.Dictionary.Synchronize()
    ReportRebut.Show()
End If
Thank you.
ramond
Posts: 5
Joined: Thu Jun 19, 2008 11:33 am

Use Procedures

Post by ramond »

Thank you very much by its aid, continuous without working.
When I execute of procedure gives back the data, but in report no. In the report the consultation of procedure works. Where I am being mistaken
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Use Procedures

Post by Edward »

Hello, Ramond.

Please replace tbReport.Show() command with tbReport.Design() command. In the Designer please check that the name of the DataSource is 'dsRpt' and you had used the DataSource with that name during designing of the report.

If you still have problems with your application, then send a test solution with a data to support[at]stimulsoft.com for analysis, please.

Thank you.
ramond
Posts: 5
Joined: Thu Jun 19, 2008 11:33 am

Use Procedures

Post by ramond »

Hello Edward,
Now with this code it works in design but not in show. Where I am being mistaken?

Dim ReportRebut As StiReport = New StiReport
ReportRebut.Load(Application.StartupPath & "\\Reports\rptRebut.mrt")
ReportRebut.Dictionary.Databases.Clear()
ReportRebut.Dictionary.DataStore.Clear()
ReportRebut.Compile()
tbReport.TableName = "dsRpt"
ReportRebut.RegData("conRpt", "conRpt", tbReport)
ReportRebut.Dictionary.DataSources.Clear()
ReportRebut.Dictionary.Synchronize()
ReportRebut.Design()
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Use Procedures

Post by Edward »

Please try to delete the following line of code:

Code: Select all

ReportRebut.Dictionary.DataSources.Clear()
I think that second time you do not need to call it.

Thank you.
ramond
Posts: 5
Joined: Thu Jun 19, 2008 11:33 am

Use Procedures

Post by ramond »

tanks Edward, now already I understand as it works
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Use Procedures

Post by Edward »

Please let us know if any help is required.

Thank you.
Post Reply