Page 1 of 1

Use Procedures

Posted: Sun Jul 06, 2008 9:45 am
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.

Use Procedures

Posted: Mon Jul 07, 2008 5:08 pm
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.

Use Procedures

Posted: Tue Jul 08, 2008 4:33 am
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

Use Procedures

Posted: Wed Jul 09, 2008 6:18 am
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.

Use Procedures

Posted: Wed Jul 09, 2008 11:16 am
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()

Use Procedures

Posted: Wed Jul 09, 2008 12:53 pm
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.

Use Procedures

Posted: Wed Jul 09, 2008 1:06 pm
by ramond
tanks Edward, now already I understand as it works

Use Procedures

Posted: Wed Jul 09, 2008 1:14 pm
by Edward
Please let us know if any help is required.

Thank you.