From: JS.staff <jsp...@ec...> - 2004-02-18 13:41:14
|
Thanks for the quick reply. This duplicates my problem. I'm sure I'm = doing (or not doing!) something dumb! Uses a simple table, TESTTABLE (id integer, username varchar(50)) Thanks, John //////////////////////////////////////////// private void tester() { FbCommand sel =3D new FbCommand("select id,username from = testtable",fbConnection1); FbCommand upd =3D new FbCommand("update testtable set username =3D = @username where id =3D @id",fbConnection1); FbCommand ins =3D new FbCommand("insert into testtable values = (@id,@username)",fbConnection1); FbCommand del =3D new FbCommand("delete from testtable where id =3D = @id",fbConnection1); upd.Parameters.Add("@username",FbDbType.VarChar); upd.Parameters.Add("@id",FbDbType.Integer); ins.Parameters.Add("@username",FbDbType.VarChar); ins.Parameters.Add("@id",FbDbType.Integer); del.Parameters.Add("@username",FbDbType.VarChar); del.Parameters.Add("@id",FbDbType.Integer); FbDataAdapter adap =3D new FbDataAdapter(); adap.SelectCommand =3D sel; adap.UpdateCommand =3D upd; adap.InsertCommand =3D ins; adap.DeleteCommand =3D del; fbConnection1.Open(); try { FbTransaction trans =3D = fbConnection1.BeginTransaction(IsolationLevel.RepeatableRead); try { sel.Transaction =3D trans; upd.Transaction =3D trans; ins.Transaction =3D trans; del.Transaction =3D trans; adap.Update(dataSet1,"something"); // which requires an update call trans.Commit(); } catch { trans.Rollback(); throw; } } finally { fbConnection1.Close(); } } /////////////////////////////////////////////// -----Original Message----- From: Carlos Guzm=E1n =C1lvarez [mailto:car...@te...]=20 Sent: 18 February 2004 12:37 To: JS.staff Cc: fir...@li... Subject: Re: [Firebird-net-provider] Using FbDataAdapter in VS 2003 Hello: > "NullReferenceException: object not set to an instance of an object" >=20 > Both Update and Insert command objects are specified. Any ideas? Can you send a test case ?? -- Best regards Carlos Guzm=E1n =C1lvarez Vigo-Spain |