Monday, March 12, 2012
parameters show previous value on second execution of report
The first time I run the report, it displays properly, with the correct info in the heading. If I change the parameters and execute it again, the data on the report changes, but the heading still shows the original parameters that I entered.
Has anyone else encountered a problem like this? Or can you suggest a solution?
Thanks,
ChrisPost the code you are using for displaying the report.|||I solved this already by using a trick that fixes another crystal problem with the navigation end page button: I commented the code in the navigate method, and called my PopulateReport method from the page load event.
I don't know why this works, but it solved the problem.
Wednesday, March 7, 2012
Parameters ignored, Render report from VB .Net application
I seem to be unable to pass parameters from a VB .Net application to Reporting Services.
Before I added the parameters to the query, I got all the rows back. So I know the application is basically working. Now that I have added the parameters, I get nothing.
I thought the SetExecutionParameters function would help, but my syntax is wrong and it fails.
I would appreciate any hint as to what step I am missing.
Report setup:
Parameters
Name Value
@.Report =Parameters!Report.Value
@.Corp =Parameters!Corp.Value
@.Dept =Parameters!Dept.Value
Query conditions
WHERE Report = 'BudgetVarianceSummary'
AND PeriodEnd = CONVERT(DateTime,CONVERT(char,GETDATE()- DATEPART(day,GETDATE()),112))
AND Report = @.Report
AND Corp = @.Corp
AND Dept = @.Dept
VB Code snippet:
Dim reportPath As String = "/FinancialReports/BudgetVarianceSummary"
Dim format As String = "PDF"
' Prepare report parameter.
Dim parameters(3) As ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "Report"
parameters(0).Value = "BudgetVarianceSummary"
parameters(1) = New ParameterValue()
parameters(1).Name = "Corp"
parameters(1).Value = "10"
parameters(2) = New ParameterValue()
parameters(2).Name = "Dept"
parameters(2).Value = "7255"
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
'This line of code fails
'rs.SetExecutionParameters(parameters, "en-us")
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
Dim DateiName As String = Benutzer.Benutzer & "_" & Date.Now.ToString("yyMMdd_HHMMss") & ".pdf"
Dim rs As New ReportingServices.ReportExecutionService
Dim Info As New ReportingServices.ExecutionInfo
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim parameters(1) As ReportingServices.ParameterValue
parameters(0) = New ReportingServices.ParameterValue()
parameters(0).Name = "KB"
parameters(0).Value = _KB
parameters(1) = New ReportingServices.ParameterValue()
parameters(1).Name = "KBG"
parameters(1).Value = CStr(_IDKBG)
Info = rs.LoadReport("/SOR/KBGDruck10", Nothing)
rs.SetExecutionParameters(parameters, "de-ch")
Dim results() As Byte
results = rs.Render("PDF", "", "", "", "", Nothing, Nothing)
Dim Stream As System.IO.FileStream = System.IO.File.OpenWrite(DateiName)
Stream.Write(results, 0, results.Length)
Stream.Close()
Windows.Forms.Cursor.Current = Cursors.Default
Try
Diagnostics.Process.Start(DateiName)
Catch ex As Exception
End Try
XInfo("", "")
Parameters ignored, Render report from VB .Net application
I seem to be unable to pass parameters from a VB .Net application to Reporting Services.
Before I added the parameters to the query, I got all the rows back. So I know the application is basically working. Now that I have added the parameters, I get nothing.
I thought the SetExecutionParameters function would help, but my syntax is wrong and it fails.
I would appreciate any hint as to what step I am missing.
Report setup:
Parameters
Name Value
@.Report =Parameters!Report.Value
@.Corp =Parameters!Corp.Value
@.Dept =Parameters!Dept.Value
Query conditions
WHERE Report = 'BudgetVarianceSummary'
AND PeriodEnd = CONVERT(DateTime,CONVERT(char,GETDATE()- DATEPART(day,GETDATE()),112))
AND Report = @.Report
AND Corp = @.Corp
AND Dept = @.Dept
VB Code snippet:
Dim reportPath As String = "/FinancialReports/BudgetVarianceSummary"
Dim format As String = "PDF"
' Prepare report parameter.
Dim parameters(3) As ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "Report"
parameters(0).Value = "BudgetVarianceSummary"
parameters(1) = New ParameterValue()
parameters(1).Name = "Corp"
parameters(1).Value = "10"
parameters(2) = New ParameterValue()
parameters(2).Name = "Dept"
parameters(2).Value = "7255"
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
'This line of code fails
'rs.SetExecutionParameters(parameters, "en-us")
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
Dim DateiName As String = Benutzer.Benutzer & "_" & Date.Now.ToString("yyMMdd_HHMMss") & ".pdf"
Dim rs As New ReportingServices.ReportExecutionService
Dim Info As New ReportingServices.ExecutionInfo
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim parameters(1) As ReportingServices.ParameterValue
parameters(0) = New ReportingServices.ParameterValue()
parameters(0).Name = "KB"
parameters(0).Value = _KB
parameters(1) = New ReportingServices.ParameterValue()
parameters(1).Name = "KBG"
parameters(1).Value = CStr(_IDKBG)
Info = rs.LoadReport("/SOR/KBGDruck10", Nothing)
rs.SetExecutionParameters(parameters, "de-ch")
Dim results() As Byte
results = rs.Render("PDF", "", "", "", "", Nothing, Nothing)
Dim Stream As System.IO.FileStream = System.IO.File.OpenWrite(DateiName)
Stream.Write(results, 0, results.Length)
Stream.Close()
Windows.Forms.Cursor.Current = Cursors.Default
Try
Diagnostics.Process.Start(DateiName)
Catch ex As Exception
End Try
XInfo("", "")
parameters from asp.net
I am new to Reporting Services so I have a basic question. I would like to
start a report from an asp.net application, and I also want to send a
parameter to the report from the asp.net page. How do I do this. Is there a
nice example somehwere that I can look at.
Thanks
JuliaIf you don't mind using the querystring method it's pretty easy to pass in a
paramater.
http://msdn2.microsoft.com/en-us/library/aa256621(SQL.80).aspx
That should have everything you need.
From the URL Access Syntax:
http://server/virtualroot?[/pathinfo]&prefix:param=value[&prefix:param=value]...n]
Just drop the prefix: to pass it a report parameter.
"Julia" wrote:
> Hi
> I am new to Reporting Services so I have a basic question. I would like to
> start a report from an asp.net application, and I also want to send a
> parameter to the report from the asp.net page. How do I do this. Is there a
> nice example somehwere that I can look at.
> Thanks
> Julia
Monday, February 20, 2012
Parameterized queries - works in Access but not SQLS2k?
to produce a filtered query.
This works fine using my Access version(see code below),
but as SQLS2k cannot use "IIF", I tried to replace these bits with
"CASE/WHEN/THEN/ELSE" lines, which does not work with numeric fields
as these cannot be "wild-carded" in the same way as Access allows.
Can anyone suggest a way forward that does not involve coding all the
possible permutations of "SELECT" blocks driven by lots of nested "IF/THEN/ELSE"s?
Hoping you can help
Alex
PARAMETERS
CurrentType Text,
CurrentCategoryID Long,
CurrentProductID Long,
CurrentClientID Long,
CurrentContractID Long,
FromDate DateTime,
ToDate DateTime;
SELECT
tAudit.AuditID,
tAudit.ActionType,
tAudit.ClientID,
tClients.ContactCompanyName,
tAudit.ContractID,
tContracts.ClientRef,
tAudit.ProductID,
tProducts.ProductName,
tAudit.CategoryID,
tCategories.CategoryName,
tAudit.Acknowledged,
tAudit.ValueAmount,
tAudit.DateStamp
FROM (((tAudit
LEFT JOIN tCategories
ON tAudit.CategoryID = tCategories.CategoryID)
LEFT JOIN tClients ON tAudit.ClientID = tClients.ClientID)
LEFT JOIN tContracts ON tAudit.ContractID = tContracts.ContractID)
LEFT JOIN tProducts ON tAudit.ProductID = tProducts.ProductID
WHERE (((tAudit.ActionType) Like IIf(IsNull([CurrentType]),"*",[CurrentType]))
AND ((tAudit.ClientID) Like IIf(IsNull([CurrentClientID]),"*",[CurrentClientID]))
AND ((tAudit.ContractID) Like IIf(IsNull([CurrentContractID]),"*",[CurrentContractID]))
AND ((tAudit.ProductID) Like IIf(IsNull([CurrentProductID]),"*",[CurrentProductID]))
AND ((tAudit.CategoryID) Like IIf(IsNull([CurrentCategoryID]),"*",[CurrentCategoryID]))
AND (([tAudit].[DateStamp]) Between [FromDate] And [ToDate]));(tAudit.ContractID) Like IIf(IsNull([CurrentContractID]),"*",[CurrentContractID])
Mdaaa...
tAudit.ContractID = isnull([CurrentContractID],tAudit.ContractID)
???|||Thanks Buser - works fine - much obliged to you!
Regards
Alex