Showing posts with label fyi. Show all posts
Showing posts with label fyi. Show all posts

Friday, March 23, 2012

FYI: Using Try's with Finally

Within my script component I was having some difficulty getting nested Exceptions to bubble out of the script component logic. The symptom appears when you get an ex.message of "Object reference not set to an instance of an object." As soon as I removed the Finally section my message (or the actual Exception object) was properly passed to the caller.

I've only done minimal work with Try/Catch/Finally structures. Is this normal?

Thanks,

Jeff Tolman
E&M Electric

Sounds like you are "swallowing" the exception. Catching it and then not doing anything with it. A code sample would be helpful.|||

Hey Jason,

No, I'm always passing on the exception. The problem comes when there is a Finally section after the Catch. The message that I throw up to the caller does not make it and shows up as the "Object reference not set to an instance of an object" message. It works fine without the Finally clause.

Jeff

|||

JazzGeek wrote:

The problem comes when there is a Finally section after the Catch. The message that I throw up to the caller does not make it and shows up as the "Object reference not set to an instance of an object" message.

I suspect the code inside Finally block fails (probably due to uninitialized variable) and throws a new exception. Could you post the code? Check that all the variables that code inside Finally uses has been assigned some objects, even if an exception is thrown before this code.

|||

I only had one line of code within the Finally block:

....
Catch ex as Exception
Throw ex
Finally
sqlReader.Close()
End Try

I ended up doing this:

....
Catch ex as Exception
Throw ex
End Try
sqlReader.Close()

which worked.

Jeff

|||

Is the sqlReader variable initialized? Most likely, when the first exception occurs, sqlReader is not assigned anything. So when you try to close null object, you get the new "Object reference not set to an instance of an object" exception, and this exception is propagated up instead of the original. If sqlReader.Close() is out of the finally scope, it is not called when first exception is thrown.

I don't think there is anything specific to SSIS here. Finally could be used in SSIS script component, but as anywhere, you should be careful to avoid throwing new exceptions inside catch or finally blocks, otherwise this new exception is propagated to next level, instead of original which is lost.

fyi: sql server 2005 service packs and hot fixes

anyone using ssis ought to consider installing sp1 and the hot fixes.

of course, these should be tested before installing on a server in production.

Also, July update for Books Online is very useful http://www.microsoft.com/downloads/details.aspx?FamilyId=BE6A2C5D-00DF-4220-B133-29C1E0B6585F&displaylang=en -

FYI: SQL Reporting Services download is available!

http://www.microsoft.com/sql/reporting/productinfo/trial.asp
If you have a SQL 2000 license, you can use the software. I don't work for
Microsoft, but I am excited enough to see this that I wanted to send out the
link. I have been waiting a long time to move beyond the limits of
Infomaker or crystal reports to something that is more integrated with SQL.
It has pdf output capabilities btw. I am going to start trying this out
immediately, I suggest DBAs check this out.
--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
*******************************************************************Just wanted to pass this along from my first attempt.
Note from the Readme file, I found you need VB .NET 2003 for the Report
designer.
Before you install the product, check for a file called authz.dll in
c:\winnt\system32. It'll hold up the install for the Reporting Services
server part if it is missing. It is a file that comes either from
contacting MS support for the file in Q320211 or from another Win 2k machine
that was upgraded from a previous service pack to SP 4 instead of SP 4
directly.
You know there always has to be prerequisites <g>
--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
*******************************************************************

FYI: SQL Reporting Services download is available!

http://www.microsoft.com/sql/report...tinfo/trial.asp
If you have a SQL 2000 license, you can use the software. I don't work for
Microsoft, but I am excited enough to see this that I wanted to send out the
link. I have been waiting a long time to move beyond the limits of
Infomaker or crystal reports to something that is more integrated with SQL.
It has pdf output capabilities btw. I am going to start trying this out
immediately, I suggest DBAs check this out.
****************************************
***************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
****************************************
***************************Just wanted to pass this along from my first attempt.
Note from the Readme file, I found you need VB .NET 2003 for the Report
designer.
Before you install the product, check for a file called authz.dll in
c:\winnt\system32. It'll hold up the install for the Reporting Services
server part if it is missing. It is a file that comes either from
contacting MS support for the file in Q320211 or from another Win 2k machine
that was upgraded from a previous service pack to SP 4 instead of SP 4
directly.
You know there always has to be prerequisites <g>
****************************************
***************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
****************************************
***************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
****************************************
***************************

FYI - Performance Tuning Tip for SQL Server 2000 with Federated Model

We just recently encountered this and I thought I'd pass it on.
If you are using SQL parameters for updates, make sure your parameters EXACTLY match the size of VARCHAR fields. If they don't, the procedures will run practically forever.
TIM ELLISON
This does not look right. Can you give an example?
Wei Xiao [MSFT]
SQL Server Storage Engine Development
http://blogs.msdn.com/weix
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Ellison" <btesubscriptions@.direcway.com> wrote in message
news:OKaxTuHtFHA.3644@.TK2MSFTNGP11.phx.gbl...
We just recently encountered this and I thought I'd pass it on.
If you are using SQL parameters for updates, make sure your parameters
EXACTLY match the size of VARCHAR fields. If they don't, the procedures
will run practically forever.
TIM ELLISON
|||Yes. I'm interested too!. Please post details.
Nik Marshall-Blank MCSD/MCDBA
"Tim Ellison" <btesubscriptions@.direcway.com> wrote in message news:OKaxTuHtFHA.3644@.TK2MSFTNGP11.phx.gbl...
We just recently encountered this and I thought I'd pass it on.
If you are using SQL parameters for updates, make sure your parameters EXACTLY match the size of VARCHAR fields. If they don't, the procedures will run practically forever.
TIM ELLISON

FYI - Performance Tuning Tip for SQL Server 2000 with Federated Model

We just recently encountered this and I thought I'd pass it on.
If you are using SQL parameters for updates, make sure your parameters EXACT
LY match the size of VARCHAR fields. If they don't, the procedures will run
practically forever.
--
TIM ELLISONThis does not look right. Can you give an example?
Wei Xiao [MSFT]
SQL Server Storage Engine Development
http://blogs.msdn.com/weix
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Ellison" <btesubscriptions@.direcway.com> wrote in message
news:OKaxTuHtFHA.3644@.TK2MSFTNGP11.phx.gbl...
We just recently encountered this and I thought I'd pass it on.
If you are using SQL parameters for updates, make sure your parameters
EXACTLY match the size of VARCHAR fields. If they don't, the procedures
will run practically forever.
TIM ELLISON|||Yes. I'm interested too!. Please post details.
--
Nik Marshall-Blank MCSD/MCDBA
"Tim Ellison" <btesubscriptions@.direcway.com> wrote in message news:OKaxTuHt
FHA.3644@.TK2MSFTNGP11.phx.gbl...
We just recently encountered this and I thought I'd pass it on.
If you are using SQL parameters for updates, make sure your parameters EXACT
LY match the size of VARCHAR fields. If they don't, the procedures will run
practically forever.
--
TIM ELLISONsql

Fyi

Hi everyone I have discovered half of my problems were due to Access 2000 apparently Access 2000 was created before SQL Server 2000 so when you try to execute a Stored Procedure through a command button and all you get are error messages its due to Access not understanding the commands. Alot of the problems I was having was due to Access 2000 now that I have Access XP I'm WALKIN ON SUNSHINE WEEELLLLLL!!! SQL Tells it to sit up, Beg, Fetch and XP just does it no questions asked...WOOHOOO

Just a little FYIand don't it feel good?