Are you sure that “fd” object is not null in line 4?

 

  Luigi.

 

p.s. (Why are you beginning a transaction only to call ExcuteNonQuery on the
command? The code works just fine even without line 8 and 10)

 

  _____  

Da: João Dias de Carvalho Neto [mailto:jdias.bjsoftw...@gmail.com] 
Inviato: martedì 5 gennaio 2010 12.40
A: For users and developers of the Firebird .NET providers
Oggetto: [Firebird-net-provider] Command.Parameters property

 

Hi,

I'm using stored procedures in Firebird to do my DAO layer with Active
Record Pattern.

In this case, I have one stored procedure called SP_UNUFDAO,

Using the Command Object, when I do this code to Persist my Object on FB:

1 - FbCommand cmd = new FbCommand("SP_UNUFDAO",Connection);
2 - cmd.CommandType = CommandType.StoredProcedure;
3 - cmd.Parameters.Add("P_ACTION",FbDbType.Smallint).Value =
CrudAction.Persist.GetHashCode();
4 - cmd.Parameters.Add("P_ACRN",FbDbType.Char,2).Value = fd.Acronym;
5 - cmd.Parameters.Add("P_DESC",FbDbType.VarChar,50).Value = fd.Description;
6 - try
7 - {
8 -     cmd.Transaction = Connection.BeginTransaction();
9 -     cmd.ExecuteNonQuery();
10 -   cmd.Transaction.Commit();
11 - }
12 - catch(Exception e)
13 - {
14 -     throw new Exception(e.Message);
15 - }

One Exception raises at line 4, something like "Object Reference not set to
an instance of object"

What's wrong on my code?

I'm using Firebird 2.1, Mono, and .Net provider 2.51

thanks

-- 
João Dias de Carvalho Neto

http://www.jdiasneto.blogspot.com
jdias.bjsoftw...@gmail.com

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to