Showing posts with label setup. Show all posts
Showing posts with label setup. Show all posts

Sunday, March 25, 2012

Backing up log file with a script setup as a job

Is there any way to include in this script below something
to tell the job to backup will the log file when it gets
to a certain percentage say 85%.
Thanks,
Aboki.
/* Script for backing up the transaction log when it is
getting full and clear the space for the log file. */
/* This can also apply to any other system but you need to
change drive and part location */
/* to match where backup location */
Backup LOG IntegraProd TO
DISK = 'D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\IntegraProdTran.bak'
GOYou could write a job to run every so often, which uses DBCC PERFLOG
to get information about log space and log space used. If log space for your
database is > 85% then issue your t-sql command.
The log is cyclic, it should wrap around and re-use empty space
where possible. It needs to keep information on the oldest active
transaction
for rollback. If your log is constantly at a certain size, this will most
likely be
right for the database anyway.
HTH
"Aboki" <waco361@.hotmail.com> wrote in message
news:08d801c3627b$37d262a0$a001280a@.phx.gbl...
> Is there any way to include in this script below something
> to tell the job to backup will the log file when it gets
> to a certain percentage say 85%.
> Thanks,
> Aboki.
>
> /* Script for backing up the transaction log when it is
> getting full and clear the space for the log file. */
> /* This can also apply to any other system but you need to
> change drive and part location */
> /* to match where backup location */
>
> Backup LOG IntegraProd TO
> DISK = 'D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\IntegraProdTran.bak'
> GO|||You can set an alert to start the job. There should be an example alert you
can modify already installed with SQL.
--
Geoff N. Hiten
SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"Aboki" <waco361@.hotmail.com> wrote in message
news:08d801c3627b$37d262a0$a001280a@.phx.gbl...
> Is there any way to include in this script below something
> to tell the job to backup will the log file when it gets
> to a certain percentage say 85%.
> Thanks,
> Aboki.
>
> /* Script for backing up the transaction log when it is
> getting full and clear the space for the log file. */
> /* This can also apply to any other system but you need to
> change drive and part location */
> /* to match where backup location */
>
> Backup LOG IntegraProd TO
> DISK = 'D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\IntegraProdTran.bak'
> GOsql

Thursday, March 8, 2012

AWE memory on SQL 2005 Standard

Is AWE enabled on SQL 2005 Standard? We currently have it setup using "locked pages in memory" for a domain account and haven't noticed any performance problems.

This article however states that only the SQL2005 Enterprise Edn supports "locked pages in memory". Can anyone confirm this?

http://support.microsoft.com/kb/918483

If I'm mistaken, how should the memory options be set for a server with 8gb ram running on SQL 2005 Standard which runs on Win2003 Enterprise? Should the min and max memory be set or left alone as default?

SQL 2005 does support AWE. However it does not support "locked pages in memory".

SQL 2005 should be set with AWE and the OS should have /3GB and /PAE in the boot.ini. This will allow Standard Edition to use all 8 Gigs of memory. Set the max memory to between 7 and 7.5 Gigs of memory.

|||

Thanks. Our current configuration has the switches /3GB and /PAE, but it wasn't clear on the "locked pages in memory". Do you know the benefit of having this feature? Also, what would you recommend our minimum memory to be set to?

Wednesday, March 7, 2012

AWE Enabled for 4gb but sqlsevr.exe only uses 74,172k

Ok, I think Im going nuts.
My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
have checked and re-checked that it is enabled. My server is using 3.57
gb out of 4gb of memory. But I use to remember that I could open the
task manager, and see the process sqlsevr.exe using 3.57 gb, but this
is not the case. I only see sqlsevr.exe using 74,172k but on the
performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
amount of memory I have available.
My question is for those of you that are running 4gb of memory on your
SQL server, if you go to task manager and look at the mem usage (you
may need to add this column in), does it show the image name
sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K ?
Anything below 2gb I would assume you do not have AWE enabled, or you
have max memory usage set low.
Just to make sure, I put in the /3gb statement in the boot.ini file,
and made sure that my security policy was to to allow Administrator to
use locked memory.
Maybe I going nuts, but I really thought task manager would show the
full amount of memory for the sqlsevr.exe process, like 3.5x something,
and not 70,xxx K.
Thank you for your help.
Steve.
ps. Running SQL SP4 with the patch for AWE.
You confirmed I am going nuts.
Thank you so much Tibor !!!
Steve.
Tibor Karaszi wrote:[vbcol=seagreen]
> Task manager isn't AWE aware. Use Perfmon instead.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <steve@.mallsoft.com> wrote in message news:1165304358.654288.142960@.79g2000cws.googlegro ups.com...

AWE Enabled for 4gb but sqlsevr.exe only uses 74,172k

Ok, I think Im going nuts.
My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
have checked and re-checked that it is enabled. My server is using 3.57
gb out of 4gb of memory. But I use to remember that I could open the
task manager, and see the process sqlsevr.exe using 3.57 gb, but this
is not the case. I only see sqlsevr.exe using 74,172k but on the
performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
amount of memory I have available.
My question is for those of you that are running 4gb of memory on your
SQL server, if you go to task manager and look at the mem usage (you
may need to add this column in), does it show the image name
sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K '
Anything below 2gb I would assume you do not have AWE enabled, or you
have max memory usage set low.
Just to make sure, I put in the /3gb statement in the boot.ini file,
and made sure that my security policy was to to allow Administrator to
use locked memory.
Maybe I going nuts, but I really thought task manager would show the
full amount of memory for the sqlsevr.exe process, like 3.5x something,
and not 70,xxx K.
Thank you for your help.
Steve.
ps. Running SQL SP4 with the patch for AWE.Task manager isn't AWE aware. Use Perfmon instead.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<steve@.mallsoft.com> wrote in message news:1165304358.654288.142960@.79g2000cws.googlegroups.com...
> Ok, I think Im going nuts.
> My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
> have checked and re-checked that it is enabled. My server is using 3.57
> gb out of 4gb of memory. But I use to remember that I could open the
> task manager, and see the process sqlsevr.exe using 3.57 gb, but this
> is not the case. I only see sqlsevr.exe using 74,172k but on the
> performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
> SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
> restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
> amount of memory I have available.
> My question is for those of you that are running 4gb of memory on your
> SQL server, if you go to task manager and look at the mem usage (you
> may need to add this column in), does it show the image name
> sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K '
> Anything below 2gb I would assume you do not have AWE enabled, or you
> have max memory usage set low.
> Just to make sure, I put in the /3gb statement in the boot.ini file,
> and made sure that my security policy was to to allow Administrator to
> use locked memory.
> Maybe I going nuts, but I really thought task manager would show the
> full amount of memory for the sqlsevr.exe process, like 3.5x something,
> and not 70,xxx K.
> Thank you for your help.
> Steve.
> ps. Running SQL SP4 with the patch for AWE.
>|||You confirmed I am going nuts.
Thank you so much Tibor !!!
Steve.
Tibor Karaszi wrote:
> Task manager isn't AWE aware. Use Perfmon instead.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <steve@.mallsoft.com> wrote in message news:1165304358.654288.142960@.79g2000cws.googlegroups.com...
> > Ok, I think Im going nuts.
> > My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
> > have checked and re-checked that it is enabled. My server is using 3.57
> > gb out of 4gb of memory. But I use to remember that I could open the
> > task manager, and see the process sqlsevr.exe using 3.57 gb, but this
> > is not the case. I only see sqlsevr.exe using 74,172k but on the
> > performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
> > SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
> > restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
> > amount of memory I have available.
> >
> > My question is for those of you that are running 4gb of memory on your
> > SQL server, if you go to task manager and look at the mem usage (you
> > may need to add this column in), does it show the image name
> > sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K '
> > Anything below 2gb I would assume you do not have AWE enabled, or you
> > have max memory usage set low.
> >
> > Just to make sure, I put in the /3gb statement in the boot.ini file,
> > and made sure that my security policy was to to allow Administrator to
> > use locked memory.
> >
> > Maybe I going nuts, but I really thought task manager would show the
> > full amount of memory for the sqlsevr.exe process, like 3.5x something,
> > and not 70,xxx K.
> >
> > Thank you for your help.
> > Steve.
> >
> > ps. Running SQL SP4 with the patch for AWE.
> >|||> You confirmed I am going nuts.
Hopefully I confirmed that you are *not* going nuts... :-)
> Thank you so much Tibor !!!
Glad I could help.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<steve@.mallsoft.com> wrote in message news:1165305317.570898.202860@.l12g2000cwl.googlegroups.com...
> You confirmed I am going nuts.
> Thank you so much Tibor !!!
> Steve.
>
> Tibor Karaszi wrote:
>> Task manager isn't AWE aware. Use Perfmon instead.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> <steve@.mallsoft.com> wrote in message
>> news:1165304358.654288.142960@.79g2000cws.googlegroups.com...
>> > Ok, I think Im going nuts.
>> > My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
>> > have checked and re-checked that it is enabled. My server is using 3.57
>> > gb out of 4gb of memory. But I use to remember that I could open the
>> > task manager, and see the process sqlsevr.exe using 3.57 gb, but this
>> > is not the case. I only see sqlsevr.exe using 74,172k but on the
>> > performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
>> > SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
>> > restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
>> > amount of memory I have available.
>> >
>> > My question is for those of you that are running 4gb of memory on your
>> > SQL server, if you go to task manager and look at the mem usage (you
>> > may need to add this column in), does it show the image name
>> > sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K '
>> > Anything below 2gb I would assume you do not have AWE enabled, or you
>> > have max memory usage set low.
>> >
>> > Just to make sure, I put in the /3gb statement in the boot.ini file,
>> > and made sure that my security policy was to to allow Administrator to
>> > use locked memory.
>> >
>> > Maybe I going nuts, but I really thought task manager would show the
>> > full amount of memory for the sqlsevr.exe process, like 3.5x something,
>> > and not 70,xxx K.
>> >
>> > Thank you for your help.
>> > Steve.
>> >
>> > ps. Running SQL SP4 with the patch for AWE.
>> >
>

AWE Enabled for 4gb but sqlsevr.exe only uses 74,172k

Ok, I think Im going nuts.
My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
have checked and re-checked that it is enabled. My server is using 3.57
gb out of 4gb of memory. But I use to remember that I could open the
task manager, and see the process sqlsevr.exe using 3.57 gb, but this
is not the case. I only see sqlsevr.exe using 74,172k but on the
performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
amount of memory I have available.
My question is for those of you that are running 4gb of memory on your
SQL server, if you go to task manager and look at the mem usage (you
may need to add this column in), does it show the image name
sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K '
Anything below 2gb I would assume you do not have AWE enabled, or you
have max memory usage set low.
Just to make sure, I put in the /3gb statement in the boot.ini file,
and made sure that my security policy was to to allow Administrator to
use locked memory.
Maybe I going nuts, but I really thought task manager would show the
full amount of memory for the sqlsevr.exe process, like 3.5x something,
and not 70,xxx K.
Thank you for your help.
Steve.
ps. Running SQL SP4 with the patch for AWE.Task manager isn't AWE aware. Use Perfmon instead.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<steve@.mallsoft.com> wrote in message news:1165304358.654288.142960@.79g2000cws.googlegroups.
com...
> Ok, I think Im going nuts.
> My SQL 2000 Enterprise is setup for AWE supprt. I turned this on and
> have checked and re-checked that it is enabled. My server is using 3.57
> gb out of 4gb of memory. But I use to remember that I could open the
> task manager, and see the process sqlsevr.exe using 3.57 gb, but this
> is not the case. I only see sqlsevr.exe using 74,172k but on the
> performance tab, the memory usage is at 3.57gb out of 4gb. If I stop
> SQL Server, then yes, memory drops from 3.57 to about 400 meg. If I
> restart SQL, it goes back up to 3.57gb. I assume SQL is using the full
> amount of memory I have available.
> My question is for those of you that are running 4gb of memory on your
> SQL server, if you go to task manager and look at the mem usage (you
> may need to add this column in), does it show the image name
> sqlsevr.exe using 3.x gig of memory or do you also see 74,xxx K '
> Anything below 2gb I would assume you do not have AWE enabled, or you
> have max memory usage set low.
> Just to make sure, I put in the /3gb statement in the boot.ini file,
> and made sure that my security policy was to to allow Administrator to
> use locked memory.
> Maybe I going nuts, but I really thought task manager would show the
> full amount of memory for the sqlsevr.exe process, like 3.5x something,
> and not 70,xxx K.
> Thank you for your help.
> Steve.
> ps. Running SQL SP4 with the patch for AWE.
>|||You confirmed I am going nuts.
Thank you so much Tibor !!!
Steve.
Tibor Karaszi wrote:[vbcol=seagreen]
> Task manager isn't AWE aware. Use Perfmon instead.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <steve@.mallsoft.com> wrote in message news:1165304358.654288.142960@.79g200
0cws.googlegroups.com...|||> You confirmed I am going nuts.
Hopefully I confirmed that you are *not* going nuts... :-)

> Thank you so much Tibor !!!
Glad I could help.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<steve@.mallsoft.com> wrote in message news:1165305317.570898.202860@.l12g2000cwl.googlegroups
.com...
> You confirmed I am going nuts.
> Thank you so much Tibor !!!
> Steve.
>
> Tibor Karaszi wrote:
>

Sunday, February 12, 2012

Auto-Save to PDF

I want to be able to automatically create and save an SQL Report (rendered as
PDF) from a link on a web page.
I know how to setup the hyperlink to open the report directly in PDF
(without the user seeing 'Report Viewer') - however I actually want to just
save the PDF without user interaction!!!
A point in the right direction would be fantastic!
Regards,
Ryan.If you want to save the report (no matter in what format) on the server
side, as long as the web app's running user account has proper permission to
the saving location, then yes, it can be saved somewhere on server side. If
you want the report to be saved on user's computer silently, no, you cannot.
Every thing downloaded to browser (except for those used by browser, such as
cookies, that are saved in Internet temporary folder) can only be saved by
user's explicit permission. That is, server side code is not allowed to
silently save something on user's computer without user's acknowledge.
"Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
news:F729834A-4EA5-4DCF-BE31-0658DD37A92A@.microsoft.com...
>I want to be able to automatically create and save an SQL Report (rendered
>as
> PDF) from a link on a web page.
> I know how to setup the hyperlink to open the report directly in PDF
> (without the user seeing 'Report Viewer') - however I actually want to
> just
> save the PDF without user interaction!!!
> A point in the right direction would be fantastic!
> Regards,
> Ryan.|||Thank you for your reply!
I do want to save server-side - so that isn't going to be a problem... i'm
just struggling to find a way of doing this 'programatically' when the user
clicks a link on an ASP webpage.
As in, the user clicks a link (then maybe using URL syntax) and a PDF
version of the report is saved server side to a specific folder... I don't
want the user to see the report (as in don't want it to open in Report Viewer
or PDF) - just create it behind the scenes.
...hope i've made sense there!
Regards,
Ryan.
"Norman Yuan" wrote:
> If you want to save the report (no matter in what format) on the server
> side, as long as the web app's running user account has proper permission to
> the saving location, then yes, it can be saved somewhere on server side. If
> you want the report to be saved on user's computer silently, no, you cannot.
> Every thing downloaded to browser (except for those used by browser, such as
> cookies, that are saved in Internet temporary folder) can only be saved by
> user's explicit permission. That is, server side code is not allowed to
> silently save something on user's computer without user's acknowledge.
>
> "Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
> news:F729834A-4EA5-4DCF-BE31-0658DD37A92A@.microsoft.com...
> >I want to be able to automatically create and save an SQL Report (rendered
> >as
> > PDF) from a link on a web page.
> >
> > I know how to setup the hyperlink to open the report directly in PDF
> > (without the user seeing 'Report Viewer') - however I actually want to
> > just
> > save the PDF without user interaction!!!
> >
> > A point in the right direction would be fantastic!
> >
> > Regards,
> >
> > Ryan.
>
>|||OK, to save a report on the server side, you can call Reporting Services'
web services to generate the report, render it in desired format and save
it.
I just write a peice of code to allow user to request a report to be send to
a given email address as an attachment. Here is the simplified code (note,
you need to add web reference to the reporting services' web services):
private void GetReportByEmail()
{
//Validate txtEmail for inputting
if (txtEmail.Text.ToUpper().StartsWith("XX"))
{
lblPrompt.Text="You must enter a valid email address!";
lblPrompt.Visible=true;
return;
}
if (txtEmail.Text.IndexOf("@.")<3)
{
lblPrompt.Text="You must enter a valid email address!";
lblPrompt.Visible=true;
return;
}
//Get report
TimeSheet.wdsg_svr003.ReportingService rs=new
TimeSheet.wdsg_svr003.ReportingService();
rs.Url="http://localhost/ReportServer/ReportService.asmx";
rs.Credentials=System.Net.CredentialCache.DefaultCredentials;
string report="/WDTimeSheets/TimeSheetEmp/PayrollSummary";
string historyID=null;
string deviceInfo=null;
TimeSheet.wdsg_svr003.ParameterValue[] pmts=new
TimeSheet.wdsg_svr003.ParameterValue[3];
TimeSheet.wdsg_svr003.ParameterValue pmt;
pmt=new TimeSheet.wdsg_svr003.ParameterValue();
pmt.Name="EmployeeID";
pmt.Value=lblEmpID.Text;
pmts[0]=pmt;
pmt=new TimeSheet.wdsg_svr003.ParameterValue();
pmt.Name="FromDate";
pmt.Value=DateTime.Parse(ddlFrom.SelectedValue).ToString("yyyy-MM-dd");
pmts[1]=pmt;
pmt=new TimeSheet.wdsg_svr003.ParameterValue();
pmt.Name="ToDate";
pmt.Value=DateTime.Parse(txtTo.Text).ToString("yyyy-MM-dd");
pmts[2]=pmt;
TimeSheet.wdsg_svr003.DataSourceCredentials[] credentials=null;
string showHide=null;
string encoding=null;
string mimetype=null;
TimeSheet.wdsg_svr003.ParameterValue[] pmtUsed=null;
TimeSheet.wdsg_svr003.Warning[] warnings=null;
string[] streamIDs=null;
byte[] reportData;
//Get report in byte array
try
{
reportData=rs.Render(report,"PDF",historyID,deviceInfo,pmts,credentials,showHide,
out encoding,out mimetype,out pmtUsed,out warnings,out streamIDs);
}
catch(System.Web.Services.Protocols.SoapException ex)
{
lblPrompt.Text=ex.Message;
lblPrompt.Visible=true;
return;
}
//Save PDF report to a temp location
string
folder=System.Configuration.ConfigurationSettings.AppSettings["TempDataFolder"];
if (Directory.Exists(folder))
{
//Get a random file name
string f="PayRollSummary_" + DateTime.Today.ToString("yyyy-MM-dd") + "_"
+ lblEmpID.Text;
string fileName=folder + "\\" + f + ".pdf";
//Save the report (PDF) in a configured location
try
{
if (File.Exists(fileName)) File.Delete(fileName);
FileStream fs=File.OpenWrite(fileName);
fs.Write(reportData,0,reportData.Length);
fs.Close();
}
catch(System.IO.IOException ex)
{
lblPrompt.Text=ex.Message;
lblPrompt.Visible=true;
return;
}
//Send PDF file with email
EmailReport(fileName); //Method is omitted
}
else
{
lblPrompt.Text="Web server configuration error: emailing operation was
cancelled.";
lblPrompt.Visible=true;
}
}
HTH
"Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
news:449D6EC9-A442-426E-AE54-370376731FFF@.microsoft.com...
> Thank you for your reply!
> I do want to save server-side - so that isn't going to be a problem... i'm
> just struggling to find a way of doing this 'programatically' when the
> user
> clicks a link on an ASP webpage.
> As in, the user clicks a link (then maybe using URL syntax) and a PDF
> version of the report is saved server side to a specific folder... I don't
> want the user to see the report (as in don't want it to open in Report
> Viewer
> or PDF) - just create it behind the scenes.
> ...hope i've made sense there!
> Regards,
> Ryan.
> "Norman Yuan" wrote:
>> If you want to save the report (no matter in what format) on the server
>> side, as long as the web app's running user account has proper permission
>> to
>> the saving location, then yes, it can be saved somewhere on server side.
>> If
>> you want the report to be saved on user's computer silently, no, you
>> cannot.
>> Every thing downloaded to browser (except for those used by browser, such
>> as
>> cookies, that are saved in Internet temporary folder) can only be saved
>> by
>> user's explicit permission. That is, server side code is not allowed to
>> silently save something on user's computer without user's acknowledge.
>>
>> "Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
>> news:F729834A-4EA5-4DCF-BE31-0658DD37A92A@.microsoft.com...
>> >I want to be able to automatically create and save an SQL Report
>> >(rendered
>> >as
>> > PDF) from a link on a web page.
>> >
>> > I know how to setup the hyperlink to open the report directly in PDF
>> > (without the user seeing 'Report Viewer') - however I actually want to
>> > just
>> > save the PDF without user interaction!!!
>> >
>> > A point in the right direction would be fantastic!
>> >
>> > Regards,
>> >
>> > Ryan.
>>|||Hi,
Sorry to be a pain... but what language is your code? (it looks like
Javascript to me...however thought it would have to be ASP / ASPX or
something server side).
I am a novice - so sorry for stupid questions!!!
Ryan.
"Norman Yuan" wrote:
> OK, to save a report on the server side, you can call Reporting Services'
> web services to generate the report, render it in desired format and save
> it.
> I just write a peice of code to allow user to request a report to be send to
> a given email address as an attachment. Here is the simplified code (note,
> you need to add web reference to the reporting services' web services):
> private void GetReportByEmail()
> {
> //Validate txtEmail for inputting
> if (txtEmail.Text.ToUpper().StartsWith("XX"))
> {
> lblPrompt.Text="You must enter a valid email address!";
> lblPrompt.Visible=true;
> return;
> }
> if (txtEmail.Text.IndexOf("@.")<3)
> {
> lblPrompt.Text="You must enter a valid email address!";
> lblPrompt.Visible=true;
> return;
> }
> //Get report
> TimeSheet.wdsg_svr003.ReportingService rs=new
> TimeSheet.wdsg_svr003.ReportingService();
> rs.Url="http://localhost/ReportServer/ReportService.asmx";
> rs.Credentials=System.Net.CredentialCache.DefaultCredentials;
> string report="/WDTimeSheets/TimeSheetEmp/PayrollSummary";
> string historyID=null;
> string deviceInfo=null;
> TimeSheet.wdsg_svr003.ParameterValue[] pmts=new
> TimeSheet.wdsg_svr003.ParameterValue[3];
> TimeSheet.wdsg_svr003.ParameterValue pmt;
> pmt=new TimeSheet.wdsg_svr003.ParameterValue();
> pmt.Name="EmployeeID";
> pmt.Value=lblEmpID.Text;
> pmts[0]=pmt;
> pmt=new TimeSheet.wdsg_svr003.ParameterValue();
> pmt.Name="FromDate";
> pmt.Value=DateTime.Parse(ddlFrom.SelectedValue).ToString("yyyy-MM-dd");
> pmts[1]=pmt;
> pmt=new TimeSheet.wdsg_svr003.ParameterValue();
> pmt.Name="ToDate";
> pmt.Value=DateTime.Parse(txtTo.Text).ToString("yyyy-MM-dd");
> pmts[2]=pmt;
> TimeSheet.wdsg_svr003.DataSourceCredentials[] credentials=null;
> string showHide=null;
> string encoding=null;
> string mimetype=null;
> TimeSheet.wdsg_svr003.ParameterValue[] pmtUsed=null;
> TimeSheet.wdsg_svr003.Warning[] warnings=null;
> string[] streamIDs=null;
> byte[] reportData;
> //Get report in byte array
> try
> {
> reportData=rs.Render(report,"PDF",historyID,deviceInfo,pmts,credentials,showHide,
> out encoding,out mimetype,out pmtUsed,out warnings,out streamIDs);
> }
> catch(System.Web.Services.Protocols.SoapException ex)
> {
> lblPrompt.Text=ex.Message;
> lblPrompt.Visible=true;
> return;
> }
> //Save PDF report to a temp location
> string
> folder=System.Configuration.ConfigurationSettings.AppSettings["TempDataFolder"];
> if (Directory.Exists(folder))
> {
> //Get a random file name
> string f="PayRollSummary_" + DateTime.Today.ToString("yyyy-MM-dd") + "_"
> + lblEmpID.Text;
> string fileName=folder + "\\" + f + ".pdf";
> //Save the report (PDF) in a configured location
> try
> {
> if (File.Exists(fileName)) File.Delete(fileName);
> FileStream fs=File.OpenWrite(fileName);
> fs.Write(reportData,0,reportData.Length);
> fs.Close();
> }
> catch(System.IO.IOException ex)
> {
> lblPrompt.Text=ex.Message;
> lblPrompt.Visible=true;
> return;
> }
> //Send PDF file with email
> EmailReport(fileName); //Method is omitted
> }
> else
> {
> lblPrompt.Text="Web server configuration error: emailing operation was
> cancelled.";
> lblPrompt.Visible=true;
> }
> }
>
> HTH
> "Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
> news:449D6EC9-A442-426E-AE54-370376731FFF@.microsoft.com...
> > Thank you for your reply!
> >
> > I do want to save server-side - so that isn't going to be a problem... i'm
> > just struggling to find a way of doing this 'programatically' when the
> > user
> > clicks a link on an ASP webpage.
> >
> > As in, the user clicks a link (then maybe using URL syntax) and a PDF
> > version of the report is saved server side to a specific folder... I don't
> > want the user to see the report (as in don't want it to open in Report
> > Viewer
> > or PDF) - just create it behind the scenes.
> >
> > ...hope i've made sense there!
> >
> > Regards,
> >
> > Ryan.
> >
> > "Norman Yuan" wrote:
> >
> >> If you want to save the report (no matter in what format) on the server
> >> side, as long as the web app's running user account has proper permission
> >> to
> >> the saving location, then yes, it can be saved somewhere on server side.
> >> If
> >> you want the report to be saved on user's computer silently, no, you
> >> cannot.
> >> Every thing downloaded to browser (except for those used by browser, such
> >> as
> >> cookies, that are saved in Internet temporary folder) can only be saved
> >> by
> >> user's explicit permission. That is, server side code is not allowed to
> >> silently save something on user's computer without user's acknowledge.
> >>
> >>
> >> "Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
> >> news:F729834A-4EA5-4DCF-BE31-0658DD37A92A@.microsoft.com...
> >> >I want to be able to automatically create and save an SQL Report
> >> >(rendered
> >> >as
> >> > PDF) from a link on a web page.
> >> >
> >> > I know how to setup the hyperlink to open the report directly in PDF
> >> > (without the user seeing 'Report Viewer') - however I actually want to
> >> > just
> >> > save the PDF without user interaction!!!
> >> >
> >> > A point in the right direction would be fantastic!
> >> >
> >> > Regards,
> >> >
> >> > Ryan.
> >>
> >>
> >>
>
>|||It is ASP.NET code in C#. Since you need to get the report in binary on
server side (reporting server), hence the ASP.NET.
"Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
news:5A8EBADD-325B-4E54-BFA8-C2206073CB5E@.microsoft.com...
> Hi,
> Sorry to be a pain... but what language is your code? (it looks like
> Javascript to me...however thought it would have to be ASP / ASPX or
> something server side).
> I am a novice - so sorry for stupid questions!!!
> Ryan.
> "Norman Yuan" wrote:
>> OK, to save a report on the server side, you can call Reporting Services'
>> web services to generate the report, render it in desired format and save
>> it.
>> I just write a peice of code to allow user to request a report to be send
>> to
>> a given email address as an attachment. Here is the simplified code
>> (note,
>> you need to add web reference to the reporting services' web services):
>> private void GetReportByEmail()
>> {
>> //Validate txtEmail for inputting
>> if (txtEmail.Text.ToUpper().StartsWith("XX"))
>> {
>> lblPrompt.Text="You must enter a valid email address!";
>> lblPrompt.Visible=true;
>> return;
>> }
>> if (txtEmail.Text.IndexOf("@.")<3)
>> {
>> lblPrompt.Text="You must enter a valid email address!";
>> lblPrompt.Visible=true;
>> return;
>> }
>> //Get report
>> TimeSheet.wdsg_svr003.ReportingService rs=new
>> TimeSheet.wdsg_svr003.ReportingService();
>> rs.Url="http://localhost/ReportServer/ReportService.asmx";
>> rs.Credentials=System.Net.CredentialCache.DefaultCredentials;
>> string report="/WDTimeSheets/TimeSheetEmp/PayrollSummary";
>> string historyID=null;
>> string deviceInfo=null;
>> TimeSheet.wdsg_svr003.ParameterValue[] pmts=new
>> TimeSheet.wdsg_svr003.ParameterValue[3];
>> TimeSheet.wdsg_svr003.ParameterValue pmt;
>> pmt=new TimeSheet.wdsg_svr003.ParameterValue();
>> pmt.Name="EmployeeID";
>> pmt.Value=lblEmpID.Text;
>> pmts[0]=pmt;
>> pmt=new TimeSheet.wdsg_svr003.ParameterValue();
>> pmt.Name="FromDate";
>> pmt.Value=DateTime.Parse(ddlFrom.SelectedValue).ToString("yyyy-MM-dd");
>> pmts[1]=pmt;
>> pmt=new TimeSheet.wdsg_svr003.ParameterValue();
>> pmt.Name="ToDate";
>> pmt.Value=DateTime.Parse(txtTo.Text).ToString("yyyy-MM-dd");
>> pmts[2]=pmt;
>> TimeSheet.wdsg_svr003.DataSourceCredentials[] credentials=null;
>> string showHide=null;
>> string encoding=null;
>> string mimetype=null;
>> TimeSheet.wdsg_svr003.ParameterValue[] pmtUsed=null;
>> TimeSheet.wdsg_svr003.Warning[] warnings=null;
>> string[] streamIDs=null;
>> byte[] reportData;
>> //Get report in byte array
>> try
>> {
>> reportData=rs.Render(report,"PDF",historyID,deviceInfo,pmts,credentials,showHide,
>> out encoding,out mimetype,out pmtUsed,out warnings,out streamIDs);
>> }
>> catch(System.Web.Services.Protocols.SoapException ex)
>> {
>> lblPrompt.Text=ex.Message;
>> lblPrompt.Visible=true;
>> return;
>> }
>> //Save PDF report to a temp location
>> string
>> folder=System.Configuration.ConfigurationSettings.AppSettings["TempDataFolder"];
>> if (Directory.Exists(folder))
>> {
>> //Get a random file name
>> string f="PayRollSummary_" + DateTime.Today.ToString("yyyy-MM-dd") +
>> "_"
>> + lblEmpID.Text;
>> string fileName=folder + "\\" + f + ".pdf";
>> //Save the report (PDF) in a configured location
>> try
>> {
>> if (File.Exists(fileName)) File.Delete(fileName);
>> FileStream fs=File.OpenWrite(fileName);
>> fs.Write(reportData,0,reportData.Length);
>> fs.Close();
>> }
>> catch(System.IO.IOException ex)
>> {
>> lblPrompt.Text=ex.Message;
>> lblPrompt.Visible=true;
>> return;
>> }
>> //Send PDF file with email
>> EmailReport(fileName); //Method is omitted
>> }
>> else
>> {
>> lblPrompt.Text="Web server configuration error: emailing operation
>> was
>> cancelled.";
>> lblPrompt.Visible=true;
>> }
>> }
>>
>> HTH
>> "Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
>> news:449D6EC9-A442-426E-AE54-370376731FFF@.microsoft.com...
>> > Thank you for your reply!
>> >
>> > I do want to save server-side - so that isn't going to be a problem...
>> > i'm
>> > just struggling to find a way of doing this 'programatically' when the
>> > user
>> > clicks a link on an ASP webpage.
>> >
>> > As in, the user clicks a link (then maybe using URL syntax) and a PDF
>> > version of the report is saved server side to a specific folder... I
>> > don't
>> > want the user to see the report (as in don't want it to open in Report
>> > Viewer
>> > or PDF) - just create it behind the scenes.
>> >
>> > ...hope i've made sense there!
>> >
>> > Regards,
>> >
>> > Ryan.
>> >
>> > "Norman Yuan" wrote:
>> >
>> >> If you want to save the report (no matter in what format) on the
>> >> server
>> >> side, as long as the web app's running user account has proper
>> >> permission
>> >> to
>> >> the saving location, then yes, it can be saved somewhere on server
>> >> side.
>> >> If
>> >> you want the report to be saved on user's computer silently, no, you
>> >> cannot.
>> >> Every thing downloaded to browser (except for those used by browser,
>> >> such
>> >> as
>> >> cookies, that are saved in Internet temporary folder) can only be
>> >> saved
>> >> by
>> >> user's explicit permission. That is, server side code is not allowed
>> >> to
>> >> silently save something on user's computer without user's acknowledge.
>> >>
>> >>
>> >> "Ryan Aldred" <RyanAldred@.discussions.microsoft.com> wrote in message
>> >> news:F729834A-4EA5-4DCF-BE31-0658DD37A92A@.microsoft.com...
>> >> >I want to be able to automatically create and save an SQL Report
>> >> >(rendered
>> >> >as
>> >> > PDF) from a link on a web page.
>> >> >
>> >> > I know how to setup the hyperlink to open the report directly in PDF
>> >> > (without the user seeing 'Report Viewer') - however I actually want
>> >> > to
>> >> > just
>> >> > save the PDF without user interaction!!!
>> >> >
>> >> > A point in the right direction would be fantastic!
>> >> >
>> >> > Regards,
>> >> >
>> >> > Ryan.
>> >>
>> >>
>> >>
>>