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