Showing posts with label event. Show all posts
Showing posts with label event. Show all posts

Wednesday, March 28, 2012

Is there a load event or run event?

Is there a load event or report run event for a report that can be accessed? I need to have my report jump to a certain url whenever it is run but I cannot use the jump to url because that has to be clicked. I need this to occur automatically. Any suggestions?
There is an OnInit event that fires each time the report is run. The method can be used in custom code like this,

Protected Overrides Sub OnInit()

' do something

End Sub

Ian|||Thank you Ian. I appreciate your response. Is there some way once I use this code that I can make it fire a url?|||You could do something like this:

Protected Overrides Sub OnInit()
Response.Redirect("MyOtherUrl.aspx")
End Sub|||Thank you so much! That sounds like exactly what I was looking for!|||I tried this and it says Name Response is not declared. Was I supposed to use it in the code window?|||Response.Redirect will not work since the code is not executed directly within the context of the page.

What you will need to do is use the WebRequest class, see example below. Also, you will need to add a reference to System.Net, using the Reference tab on the Report Properties dialog.

Protected Overrides Sub OnInit()
Dim request As WebRequest = WebRequest.Create("http://www.example.com")
Dim response As WebResponse = request.GetResponse()

End Sub

Ian|||Do I have to create a custom assembly or can I use the code in the code window? I do not know what to enter on the references tab. Thank you so very much for your patience.|||Yes, you can use the Code section in the in the Report properties window.

Actually, I was mistaken. You do not need to add any thing in the References Tab. The Classes you need are in the System.Net namespace and are contained in System.dll.

Since this is the case, all you will need to so is add the namespace to the beginning of all the WebRequest and WebResponse class names, something like,

Protected Overrides Sub OnInit()

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.example.com")
Dim response As System.Net.WebResponse = request.GetResponse()

End Sub

Ian|||I tried this but got an error. "An error occurred while executing OnInit: The remote server returned an error: (401) Unauthorized.|||This means that the server you are trying to hit is not allowing anonymous access. Take a look at the link below on how to supply user credentials.

http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx

Ian|||

I tried the exact same thing

Protected Overrides Sub OnInit()

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.example.com")
Dim response As System.Net.WebResponse = request.GetResponse()

End Sub

And that did not work, So I tried putting a msgbox in the routine and the msgbox did not pop up. So i am not sure why the routine is not getting called

?

|||The routine is probably getting called, but is not doing anything visibly--just silently hitting a web site. And, the message box may not appear since the context the code is executing is not graphical.

Try this, place a Textbox on the report with the expression "=Code.GetLength()", and place the following in the Code section. You should see the length of the response in the Textbox.

Private m_length as Integer

Protected Overrides Sub OnInit()

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.example.com")
Dim response As System.Net.WebResponse = request.GetResponse()
m_length = response.ContentLength
End Sub

Function GetLength() As Integer
Return m_length
End Function

Ian|||We could not get this to work correctly (Redirect w/ getting the user credentials). Could you show me a sample with both being done?|||

I still cannot get it to work. I do see the report trying to do something but not actually redirecting the entire page. Are there any permissions I need to set to allow such actions for a anonymous user?

Thanks.

Is there a load event or run event?

Is there a load event or report run event for a report that can be accessed? I need to have my report jump to a certain url whenever it is run but I cannot use the jump to url because that has to be clicked. I need this to occur automatically. Any suggestions?
There is an OnInit event that fires each time the report is run. The method can be used in custom code like this,

Protected Overrides Sub OnInit()

' do something

End Sub

Ian|||Thank you Ian. I appreciate your response. Is there some way once I use this code that I can make it fire a url?|||You could do something like this:

Protected Overrides Sub OnInit()
Response.Redirect("MyOtherUrl.aspx")
End Sub|||Thank you so much! That sounds like exactly what I was looking for!|||I tried this and it says Name Response is not declared. Was I supposed to use it in the code window?|||Response.Redirect will not work since the code is not executed directly within the context of the page.

What you will need to do is use the WebRequest class, see example below. Also, you will need to add a reference to System.Net, using the Reference tab on the Report Properties dialog.

Protected Overrides Sub OnInit()
Dim request As WebRequest = WebRequest.Create("http://www.example.com")
Dim response As WebResponse = request.GetResponse()

End Sub

Ian|||Do I have to create a custom assembly or can I use the code in the code window? I do not know what to enter on the references tab. Thank you so very much for your patience.|||Yes, you can use the Code section in the in the Report properties window.

Actually, I was mistaken. You do not need to add any thing in the References Tab. The Classes you need are in the System.Net namespace and are contained in System.dll.

Since this is the case, all you will need to so is add the namespace to the beginning of all the WebRequest and WebResponse class names, something like,

Protected Overrides Sub OnInit()

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.example.com")
Dim response As System.Net.WebResponse = request.GetResponse()

End Sub

Ian|||I tried this but got an error. "An error occurred while executing OnInit: The remote server returned an error: (401) Unauthorized.|||This means that the server you are trying to hit is not allowing anonymous access. Take a look at the link below on how to supply user credentials.

http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx

Ian|||

I tried the exact same thing

Protected Overrides Sub OnInit()

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.example.com")
Dim response As System.Net.WebResponse = request.GetResponse()

End Sub

And that did not work, So I tried putting a msgbox in the routine and the msgbox did not pop up. So i am not sure why the routine is not getting called

?

|||The routine is probably getting called, but is not doing anything visibly--just silently hitting a web site. And, the message box may not appear since the context the code is executing is not graphical.

Try this, place a Textbox on the report with the expression "=Code.GetLength()", and place the following in the Code section. You should see the length of the response in the Textbox.

Private m_length as Integer

Protected Overrides Sub OnInit()

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.example.com")
Dim response As System.Net.WebResponse = request.GetResponse()
m_length = response.ContentLength
End Sub

Function GetLength() As Integer
Return m_length
End Function

Ian|||We could not get this to work correctly (Redirect w/ getting the user credentials). Could you show me a sample with both being done?|||

I still cannot get it to work. I do see the report trying to do something but not actually redirecting the entire page. Are there any permissions I need to set to allow such actions for a anonymous user?

Thanks.

Monday, February 20, 2012

Is My Backup Plan Safe?

I need to setup an online backup mechanism which allows restoration of data
up to point of failure in the event of DB file corruption or hard disk drive
failure. The current DB size is ~ 100M with a growth rate of ~15M/month for
the last 6 months. I'm thinking of :
1. Create a scheduled daily full backup from c drive to d drive
2. Create a scheduled hourly transaction log backup from c drive to d drive
3. Create a scheduled weekly full backup of backup folder in d drive to tape
drive with Windows backup utility.
4. Create scheduled daily differential backup of backup folder in d drive to
tape drive with Windows backup utility.
5. Two tapes will be rotated every alternate week for backup to tapes. Tape
not in used will be taken off-site.
Is the above plan good enough for the recovery scenario I want to address?Ong
Yep it looks pretty good. But remember that everything you did so far has
no value if you cannot restore the database. Verify that backups are not
corrupted and you can easily restore the database
"Ong" <Ong@.discussions.microsoft.com> wrote in message
news:68837F91-E41F-4487-B673-9316EE9D9037@.microsoft.com...
>I need to setup an online backup mechanism which allows restoration of data
> up to point of failure in the event of DB file corruption or hard disk
> drive
> failure. The current DB size is ~ 100M with a growth rate of ~15M/month
> for
> the last 6 months. I'm thinking of :
> 1. Create a scheduled daily full backup from c drive to d drive
> 2. Create a scheduled hourly transaction log backup from c drive to d
> drive
> 3. Create a scheduled weekly full backup of backup folder in d drive to
> tape
> drive with Windows backup utility.
> 4. Create scheduled daily differential backup of backup folder in d drive
> to
> tape drive with Windows backup utility.
> 5. Two tapes will be rotated every alternate week for backup to tapes.
> Tape
> not in used will be taken off-site.
> Is the above plan good enough for the recovery scenario I want to address?|||Thank you for your comment & precaution on backup verification.
"Uri Dimant" wrote:
> Ong
> Yep it looks pretty good. But remember that everything you did so far has
> no value if you cannot restore the database. Verify that backups are not
> corrupted and you can easily restore the database
> "Ong" <Ong@.discussions.microsoft.com> wrote in message
> news:68837F91-E41F-4487-B673-9316EE9D9037@.microsoft.com...
> >I need to setup an online backup mechanism which allows restoration of data
> > up to point of failure in the event of DB file corruption or hard disk
> > drive
> > failure. The current DB size is ~ 100M with a growth rate of ~15M/month
> > for
> > the last 6 months. I'm thinking of :
> > 1. Create a scheduled daily full backup from c drive to d drive
> > 2. Create a scheduled hourly transaction log backup from c drive to d
> > drive
> > 3. Create a scheduled weekly full backup of backup folder in d drive to
> > tape
> > drive with Windows backup utility.
> > 4. Create scheduled daily differential backup of backup folder in d drive
> > to
> > tape drive with Windows backup utility.
> > 5. Two tapes will be rotated every alternate week for backup to tapes.
> > Tape
> > not in used will be taken off-site.
> >
> > Is the above plan good enough for the recovery scenario I want to address?
>
>|||Is the C and D drive the same physical drive? Then you could lose you
database drive and your backup drive.
If C and D are separate physical drives are they on the same disk
controller? If the controller fails then you won't be able to access your
database and backups until you replace the controller or put the drive in
another box..
Imagine your server and tape drive are stolen. It sounds like you would have
to go to tape and possibly lose a week of transactions.
I would backup across the network or directly to the tape drive or get a
separate external hard drive. If your only moving data offsite once a week
get a fireproof safe.
I don't think your backup plan is safe and I don't believe you will be able
to restore to the point of failure if say your building burns down.
"Ong" <Ong@.discussions.microsoft.com> wrote in message
news:68837F91-E41F-4487-B673-9316EE9D9037@.microsoft.com...
> I need to setup an online backup mechanism which allows restoration of
data
> up to point of failure in the event of DB file corruption or hard disk
drive
> failure. The current DB size is ~ 100M with a growth rate of ~15M/month
for
> the last 6 months. I'm thinking of :
> 1. Create a scheduled daily full backup from c drive to d drive
> 2. Create a scheduled hourly transaction log backup from c drive to d
drive
> 3. Create a scheduled weekly full backup of backup folder in d drive to
tape
> drive with Windows backup utility.
> 4. Create scheduled daily differential backup of backup folder in d drive
to
> tape drive with Windows backup utility.
> 5. Two tapes will be rotated every alternate week for backup to tapes.
Tape
> not in used will be taken off-site.
> Is the above plan good enough for the recovery scenario I want to address?|||Terri ,
Thanks for your important input.
I didn't check this thread for a few days & only saw your reply today.
I hope you can clarify my questions below:
"Terri" wrote:
> Is the C and D drive the same physical drive? Then you could lose you
> database drive and your backup drive.
> If C and D are separate physical drives are they on the same disk
> controller? If the controller fails then you won't be able to access your
> database and backups until you replace the controller or put the drive in
> another box..
FYI, D is an external usb drive
> Imagine your server and tape drive are stolen. It sounds like you would have
> to go to tape and possibly lose a week of transactions.
> I would backup across the network or directly to the tape drive or get a
> separate external hard drive.
Will backup across the network be slow and cause network jam?
>If your only moving data offsite once a week
> get a fireproof safe.
Do you mean to put the tape in a fireproof safe in the office or offsite?
> I don't think your backup plan is safe and I don't believe you will be able
> to restore to the point of failure if say your building burns down.
Sounds like for solution with tape, the only safe way is to use 7 (or 5
excluding weekends) backup tapes to do full db backup daily and transaction
logs backup hourly and keep all the unused tapes offsite.