I am trying to find the best way (as well as sample code) to render a report
(probably in PDf format) to a shared directory when the user clicks on a
button called from a web page. The report should be converted to PDF and
placed in a predefined location without any interaction from the user ,
except the click of course. Any ideas, sites, sample code?here is some sample code (using VS.net 2005 against RS 2000)
to make the web reference, right click on 'references' and 'add web reference'
then enter
http://<servername>/reportserver/reportservice.asmx
and name/rename it 'reportservice' to match with my sample
this is just in a win32 vb.net form with a button to run the code
Private Sub ReportGen(ByVal OutputFormat As String, ByVal ReportLocation As
String, ByVal startdt As String, ByVal enddt As String, ByVal CustRepGp As
Integer, ByVal CustName As String)
Dim rs As New ReportService.ReportingService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
' Render arguments
Dim result As Byte() = Nothing
Dim reportPath As String = ReportLocation
Dim format As String = OutputFormat
Dim historyID As String = Nothing
Dim devInfo As String ="<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
'this report takes 3 parameters - if you don't use any then scrap this bit
'N.B. the parameter names are case sensitive as per what you called them in
the
'report designer (you can also check using report
manger-properties-parameters)
Dim parameters(2) As ReportService.ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "startDate"
parameters(0).Value = startdt.ToString()
parameters(1) = New ParameterValue()
parameters(1).Name = "endDate"
parameters(1).Value = enddt.ToString()
parameters(2) = New ParameterValue()
parameters(2).Name = "OpsCustGroupID"
parameters(2).Value = CustRepGp.ToString()
Dim credentials As DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String
Dim mimeType As String
Dim warnings As Warning() = Nothing
Dim reportHistoryParameters As ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim sh As New SessionHeader()
rs.SessionHeaderValue = sh
Try
'this is the important bit, this is calling the RENDER method on the report
web service
result = rs.Render(reportPath, format, historyID, devInfo,
parameters, credentials, showHideToggle, encoding, mimeType,
reportHistoryParameters, warnings, streamIDs)
sh.SessionId = rs.SessionHeaderValue.SessionId
Console.WriteLine("SessionID after call to Render: {0}",
rs.SessionHeaderValue.SessionId)
Console.WriteLine("Execution date and time: {0}",
rs.SessionHeaderValue.ExecutionDateTime)
Console.WriteLine("Is new execution: {0}",
rs.SessionHeaderValue.IsNewExecution)
Catch err As Exception
Console.WriteLine(err.Message)
End Try
' Write the contents of the report to an MHTML file.
Try
'need to change EXCEL to XLS otherwise the app won't recognise it
Dim fileout As String = CustName & "_" & startdt & "_" & enddt &
"." & IIf(OutputFormat = "EXCEL", "XLS", OutputFormat)
Dim stream As FileStream = File.Create("YOUR_FOLDER\" & fileout,
result.Length)
Console.WriteLine("File created: " & fileout)
stream.Write(result, 0, result.Length)
Console.WriteLine("Result written to the file.")
stream.Close()
Catch err As Exception
Console.WriteLine(err.Message)
End Try
End Sub
'in order to call the above code you will need something like
ReportGen("YOUR FORMAT e.g. PDF",
"/folderonReportServer/anotherfolder/REPORTNAME", "MY PARAM 0", "MY PARAM 1",
ANOTHERPARAM, AnotherParamforNamingTheFileOnly)
obviously you can export to other formats
N.B. all non HTML formats come back in a single stream so you can use this
example, can't remember how you do it in HTML but it's pretty similar
"Bon733" wrote:
> I am trying to find the best way (as well as sample code) to render a report
> (probably in PDf format) to a shared directory when the user clicks on a
> button called from a web page. The report should be converted to PDF and
> placed in a predefined location without any interaction from the user ,
> except the click of course. Any ideas, sites, sample code?|||Hey Adolf,
I am quite new to this kind of thing, but this is exactly what I'm trying
to do (autorender to pdf). I am having a couple of difficulties however
trying to understand it all. I have a couple basic questions (I think).
I've created a simple 1 form vb.net application with a button that says
"Create PDF".
For simplicity I've hard coded my 1 parameter (the Invoice Number "Id")
I've modified your code to the point where VB has no errors but Im missing
some values for variables.
1. ReportLocation: How do I determine this? Is this a network location
where the .rdl exists, or is this the ReportServer URL that I see if I access
the report through ReportManager, or is it something else...? Also, should
this include .rdl extension
2. Where does the PDF get created? I'm not sure I understand where the
output goes, as I'm not providing it with a "dump" location
Any help you can give me is greatly appreciated ...
Michael C
"adolf garlic" wrote:
> here is some sample code (using VS.net 2005 against RS 2000)
> to make the web reference, right click on 'references' and 'add web reference'
> then enter
> http://<servername>/reportserver/reportservice.asmx
> and name/rename it 'reportservice' to match with my sample
> this is just in a win32 vb.net form with a button to run the code
> Private Sub ReportGen(ByVal OutputFormat As String, ByVal ReportLocation As
> String, ByVal startdt As String, ByVal enddt As String, ByVal CustRepGp As
> Integer, ByVal CustName As String)
> Dim rs As New ReportService.ReportingService()
> rs.Credentials = System.Net.CredentialCache.DefaultCredentials
> ' Render arguments
> Dim result As Byte() = Nothing
> Dim reportPath As String = ReportLocation
> Dim format As String = OutputFormat
> Dim historyID As String = Nothing
> Dim devInfo As String => "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
> ' Prepare report parameter.
> 'this report takes 3 parameters - if you don't use any then scrap this bit
> 'N.B. the parameter names are case sensitive as per what you called them in
> the
> 'report designer (you can also check using report
> manger-properties-parameters)
> Dim parameters(2) As ReportService.ParameterValue
> parameters(0) = New ParameterValue()
> parameters(0).Name = "startDate"
> parameters(0).Value = startdt.ToString()
> parameters(1) = New ParameterValue()
> parameters(1).Name = "endDate"
> parameters(1).Value = enddt.ToString()
> parameters(2) = New ParameterValue()
> parameters(2).Name = "OpsCustGroupID"
> parameters(2).Value = CustRepGp.ToString()
> Dim credentials As DataSourceCredentials() = Nothing
> Dim showHideToggle As String = Nothing
> Dim encoding As String
> Dim mimeType As String
> Dim warnings As Warning() = Nothing
> Dim reportHistoryParameters As ParameterValue() = Nothing
> Dim streamIDs As String() = Nothing
> Dim sh As New SessionHeader()
> rs.SessionHeaderValue = sh
> Try
> 'this is the important bit, this is calling the RENDER method on the report
> web service
> result = rs.Render(reportPath, format, historyID, devInfo,
> parameters, credentials, showHideToggle, encoding, mimeType,
> reportHistoryParameters, warnings, streamIDs)
> sh.SessionId = rs.SessionHeaderValue.SessionId
> Console.WriteLine("SessionID after call to Render: {0}",
> rs.SessionHeaderValue.SessionId)
> Console.WriteLine("Execution date and time: {0}",
> rs.SessionHeaderValue.ExecutionDateTime)
> Console.WriteLine("Is new execution: {0}",
> rs.SessionHeaderValue.IsNewExecution)
> Catch err As Exception
> Console.WriteLine(err.Message)
> End Try
> ' Write the contents of the report to an MHTML file.
> Try
> 'need to change EXCEL to XLS otherwise the app won't recognise it
> Dim fileout As String = CustName & "_" & startdt & "_" & enddt &
> "." & IIf(OutputFormat = "EXCEL", "XLS", OutputFormat)
> Dim stream As FileStream = File.Create("YOUR_FOLDER\" & fileout,
> result.Length)
> Console.WriteLine("File created: " & fileout)
> stream.Write(result, 0, result.Length)
> Console.WriteLine("Result written to the file.")
> stream.Close()
> Catch err As Exception
> Console.WriteLine(err.Message)
> End Try
> End Sub
> 'in order to call the above code you will need something like
> ReportGen("YOUR FORMAT e.g. PDF",
> "/folderonReportServer/anotherfolder/REPORTNAME", "MY PARAM 0", "MY PARAM 1",
> ANOTHERPARAM, AnotherParamforNamingTheFileOnly)
>
> obviously you can export to other formats
> N.B. all non HTML formats come back in a single stream so you can use this
> example, can't remember how you do it in HTML but it's pretty similar
>
> "Bon733" wrote:
> > I am trying to find the best way (as well as sample code) to render a report
> > (probably in PDf format) to a shared directory when the user clicks on a
> > button called from a web page. The report should be converted to PDF and
> > placed in a predefined location without any interaction from the user ,
> > except the click of course. Any ideas, sites, sample code?sql
Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts
Wednesday, March 28, 2012
Friday, March 23, 2012
Pblm with Nested transactions
Friends,
I've a very basic doubt with Nested transactions (across procedures) in SQL Server and i guess the given below sample code illustarates my doubt well more than my words ..
I've a Proc1 like this
create procedure sp_proc1
as
begin
begin tran sp_proc1
insert into tab1 values (1,2)
exec sp_proc2 1
if <Some cdn statement>
rollback tran sp_proc1
else
commit tran sp_proc1
end
and called proc sp_proc2 is like this
create procedure sp_proc2
(
@.val1 int
)
as
begin tran proc2
update tab2 set col1 = 5
IF <some cdn statement>
begin
rollback tran proc2
end
else
begin
commit tran proc2
end
The pblm is when the 1st proc is executed and when the cdn statement in the 2nd proc is sucess, then it results with the error
Failed to retreive execution plan: Cannot roll back proc2. No transaction or savepoint of that name was found.
any suggestions
--SQLPgmrbegin tran proc2
update tab2 set col1 = 5
IF <some cdn statement> << Checking your tab2 but it still in tran !
begin
...
I think you probably are trying to check some thing that you are not commit yet!
I've a very basic doubt with Nested transactions (across procedures) in SQL Server and i guess the given below sample code illustarates my doubt well more than my words ..
I've a Proc1 like this
create procedure sp_proc1
as
begin
begin tran sp_proc1
insert into tab1 values (1,2)
exec sp_proc2 1
if <Some cdn statement>
rollback tran sp_proc1
else
commit tran sp_proc1
end
and called proc sp_proc2 is like this
create procedure sp_proc2
(
@.val1 int
)
as
begin tran proc2
update tab2 set col1 = 5
IF <some cdn statement>
begin
rollback tran proc2
end
else
begin
commit tran proc2
end
The pblm is when the 1st proc is executed and when the cdn statement in the 2nd proc is sucess, then it results with the error
Failed to retreive execution plan: Cannot roll back proc2. No transaction or savepoint of that name was found.
any suggestions
--SQLPgmrbegin tran proc2
update tab2 set col1 = 5
IF <some cdn statement> << Checking your tab2 but it still in tran !
begin
...
I think you probably are trying to check some thing that you are not commit yet!
Wednesday, March 7, 2012
Password Generating Stored Proceedure
Hi
Does anyone know of any sample stored proceedure code for a random password
generator where I can set the character lenght to 6.
Any help would be much appreciated
Thanks
BenMay be something like
SELECT LEFT(CONVERT(VARCHAR(40), NewID()),6)
?
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Ben" <Ben@.NoSpam.com> wrote in message
news:uz%23H8hDEFHA.3648@.TK2MSFTNGP10.phx.gbl...
> Hi
> Does anyone know of any sample stored proceedure code for a random
> password generator where I can set the character lenght to 6.
> Any help would be much appreciated
> Thanks
> Ben
>|||Ben wrote:
> Does anyone know of any sample stored proceedure code for a random passwor
d
> generator where I can set the character lenght to 6.
Check out http://vyaskn.tripod.com/code/password.txt
Aaron Weiker
http://aaronweiker.com/
http://www.sqlprogrammer.org/|||There is an old DEC Unix routine that produced pronouncable nonsense
words of 6 to 8 letters. You can probably find it in C.
Then Compuserve used to issue two-word phrases of the form
<adjective><noun> ("vivid*bagpipes") that were easy to remember, but
really hard to hack.
My favorite is a "bingo card" of numbers that you issue to users. The
computer challenges them with a pair of numbers; the user locates them
on his card, then replies with the numbers on the other two corners of
a rectangle marked by the first pair.
You then issue a new bingo card each month for security. Even a 5x5
grid has 600 possible challenges.|||"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1108229446.247063.307450@.g14g2000cwa.googlegroups.com...
> You then issue a new bingo card each month for security. Even a 5x5
> grid has 600 possible challenges.
A bit off topic: Due to symmetry, this Bingo card only has 200 unique
challenges that form rectangles. If you allow the challenge numbers to
come from the same file (row or column) then you have 290 unique
challenges but the response to those extra 90 will be equal to the
challenge.
Regards,
Jim
Does anyone know of any sample stored proceedure code for a random password
generator where I can set the character lenght to 6.
Any help would be much appreciated
Thanks
BenMay be something like
SELECT LEFT(CONVERT(VARCHAR(40), NewID()),6)
?
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Ben" <Ben@.NoSpam.com> wrote in message
news:uz%23H8hDEFHA.3648@.TK2MSFTNGP10.phx.gbl...
> Hi
> Does anyone know of any sample stored proceedure code for a random
> password generator where I can set the character lenght to 6.
> Any help would be much appreciated
> Thanks
> Ben
>|||Ben wrote:
> Does anyone know of any sample stored proceedure code for a random passwor
d
> generator where I can set the character lenght to 6.
Check out http://vyaskn.tripod.com/code/password.txt
Aaron Weiker
http://aaronweiker.com/
http://www.sqlprogrammer.org/|||There is an old DEC Unix routine that produced pronouncable nonsense
words of 6 to 8 letters. You can probably find it in C.
Then Compuserve used to issue two-word phrases of the form
<adjective><noun> ("vivid*bagpipes") that were easy to remember, but
really hard to hack.
My favorite is a "bingo card" of numbers that you issue to users. The
computer challenges them with a pair of numbers; the user locates them
on his card, then replies with the numbers on the other two corners of
a rectangle marked by the first pair.
You then issue a new bingo card each month for security. Even a 5x5
grid has 600 possible challenges.|||"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1108229446.247063.307450@.g14g2000cwa.googlegroups.com...
> You then issue a new bingo card each month for security. Even a 5x5
> grid has 600 possible challenges.
A bit off topic: Due to symmetry, this Bingo card only has 200 unique
challenges that form rectangles. If you allow the challenge numbers to
come from the same file (row or column) then you have 290 unique
challenges but the response to those extra 90 will be equal to the
challenge.
Regards,
Jim
Subscribe to:
Posts (Atom)