p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=138)
-   -   IDbCommand Interface (http://p2p.wrox.com/showthread.php?t=63162)

goser October 23rd, 2007 07:27 PM

IDbCommand Interface
 
I need to create a class to connect two databases (SQL & Sybase). Also execute Stored procedure and sql statements.

I'm using the interface IDbCommand to set the object command created depends on the dabase selected.

I have a Sybase stored procedure with one input parameter and one output parameter. I created two object ASEParameter and set at the Parameter's interface property.

When I execute the SP using the ExecuteNonQuery method, I check the value's output parameter
and it returns

'((Sybase.Data.AseClient.AseParameter)((new System.Collections.ArrayList.ArrayListDebugView(_o Comando.Parameters)).Items[1])).Value' threw an exception of type 'System.NullReferenceException'

But when I do the same procedure using SqlParameters and SQL Server stored procedure, it returns a correct value.

What it's the difference?

Whats wrong?

Regards


samjudson October 24th, 2007 03:14 AM

You need to do some checking to find out what exactly is null.

Is _oCommando null?
Is _oCommando.Parameters null?
Is _oCommando.Parameters.Count equal to 2?
Is _oCommando.Parameters[1] of type AseParameter?
Is _oCommando.Parameters[1].Value null?

Obvious if its the latter then your stored procedure isn't setting the return value properly by the looks of it.


/- Sam Judson : Wrox Technical Editor -/


All times are GMT -4. The time now is 11:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.