Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 6058451279 for ; Thu, 26 Jan 2012 02:36:51 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RqIx1-0003mM-4A for pgsql-bugs@postgresql.org; Thu, 26 Jan 2012 06:36:51 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RqIwo-0007nB-Lf for pgsql-bugs@postgresql.org; Thu, 26 Jan 2012 06:36:38 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1RqIwo-0007dl-Dq for pgsql-bugs@postgresql.org; Thu, 26 Jan 2012 06:36:38 +0000 Date: Thu, 26 Jan 2012 06:36:38 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6409: [NPGSQL]Fail to cast Int64 to System.Data.Common.DbParameter To: pgsql-bugs@postgresql.org From: aaron.kb.h@gmail.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/174 X-Sequence-Number: 32241 The following bug has been logged on the website: Bug reference: 6409 Logged by: AaronHuang Email address: aaron.kb.h@gmail.com PostgreSQL version: 9.1.2 Operating system: Windows 7 Ultimate Description: = [Exception] InvalidCastException:Unable to cast object of type 'System.Int64' to type 'System.Data.Common.DbParameter'. [callstack] at System.Data.Common.DbParameterCollection.System.Collections.IList.set_Item(= Int32 index, Object value) at Kelly.TcsStatus.BackUp(DateTime fromTime, DateTime toTime, Int64[] tcsIds, Int64[] statusIds, Int32[] versions) in XXXXX [important] I use IDbCommand than NpgsqlCommand. = [code sample (not runable, only FYI)] Int64 id =3D 100; ... IDbCommand cmd =3D conn.CreateCommand(); NpgsqlParameter pkParameter =3D new NpgsqlParameter("id", NpgsqlDbType.Bigint); ... cmd.Parameters.Add(pkParameter); ... cmd.Parameters[0] =3D id;// throw exception here.