Get "Unable to cast" error when calling ExecuteArray

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
eekstein
Posts: 3
Joined: Tue 13 Sep 2011 15:23

Get "Unable to cast" error when calling ExecuteArray

Post by eekstein » Tue 13 Sep 2011 15:39

I receive "Unable to cast object of type "System.String" to type "Devart.Data.Oracle.OracleLob". I am attempting insert two rows. 4 of the columns in both rows contain an empty string. I suspect this is the culprit but have no idea how to get around it. I received the error in both versions 6.30.160 and 6.540.214.

Here is code that should be able to reproduce the problem.

Code: Select all

using System;
using System.Data;
using Devart.Data.Oracle;

namespace TestExecuteArray
{
	class Program
	{
		static void Main()
		{
			TestExecuteArray();
		}

		static void TestExecuteArray()
		{
			using (OracleConnection conn = new OracleConnection("Direct=true;Server=;SID=ORCL;User ID=BusCont;Password=;Pass Parameters By Name=true;"))
			{
				conn.Open();
				using (OracleCommand cmd = conn.CreateCommand())
				{
					using (OracleTransaction transaction = conn.BeginTransaction())
					{
						cmd.CommandText = "INSERT INTO \"BUSINESS_CALLING_TREE\" (\"PARENTCONTENTID\", \"CONTENTID\", \"FIRST_PUBLISHED_DATE\", \"FIRST_PUBLISHED_USERNAME\", \"FIRST_PUBLISHED_DISPLAYNAME\", \"LAST_UPDATED_DATE\", \"LAST_UPDATED_USERNAME\", \"LAST_UPDATED_DISPLAYNAME\", \"PHONE_BUSINESS_DIRECT\", \"PHONE_HOME\", \"PHONE_MOBILE\", \"EMAIL_BUSINESS\") VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12)";

						cmd.Parameters.Add(new OracleParameter("1", OracleDbType.Integer) { Direction = ParameterDirection.Input, Value = new[] { 123670, 123812 } });
						cmd.Parameters.Add(new OracleParameter("2", OracleDbType.Integer) { Direction = ParameterDirection.Input, Value = new[] { 123669, 123811 } });
						cmd.Parameters.Add(new OracleParameter("3", OracleDbType.Date) { Direction = ParameterDirection.Input, Value = new[] { new DateTime(2001, 7, 29), new DateTime(2001, 8, 16) } });
						cmd.Parameters.Add(new OracleParameter("4", OracleDbType.NClob) { Direction = ParameterDirection.Input, Value = new[] { "ema", "ema" } });
						cmd.Parameters.Add(new OracleParameter("5", OracleDbType.NClob) { Direction = ParameterDirection.Input, Value = new[] { "Mas, Eh", "Mas, Eh" } });
						cmd.Parameters.Add(new OracleParameter("6", OracleDbType.Date) { Direction = ParameterDirection.Input, Value = new[] { new DateTime(2001, 7, 29), new DateTime(2001, 8, 16) } });
						cmd.Parameters.Add(new OracleParameter("7", OracleDbType.NClob) { Direction = ParameterDirection.Input, Value = new[] { "ema", "ema" } });
						cmd.Parameters.Add(new OracleParameter("8", OracleDbType.NClob) { Direction = ParameterDirection.Input, Value = new[] { "Mas, Eh", "Mas, Eh" } });

						cmd.Parameters.Add(new OracleParameter("9", OracleDbType.NClob)
						{
							Direction = ParameterDirection.Input,
							Value = new[] { "", "" }
						});
						cmd.Parameters.Add(new OracleParameter("10", OracleDbType.NClob)
						{
							Direction = ParameterDirection.Input,
							Value = new[] { "", "" }
						});
						cmd.Parameters.Add(new OracleParameter("11", OracleDbType.NClob)
						{
							Direction = ParameterDirection.Input,
							Value = new[] { "", "" }
						});
						cmd.Parameters.Add(new OracleParameter("12", OracleDbType.NClob)
						{
							Direction = ParameterDirection.Input,
							Value = new[] { "", "" }
						});

						cmd.ExecuteArray(2);

						transaction.Rollback();
					}
				}
			}
		}

	}
}

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 16 Sep 2011 17:27

We have reproduced the error. We will investigate the issue and notify you about the results as soon as possible.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Get "Unable to cast" error when calling ExecuteArray

Post by Pinturiccio » Wed 29 Aug 2012 10:53

We have fixed the bug with the ExecuteArray method when one of parameters is an empty NClob. We will post here when the corresponding build of dotConnect for Oracle is available for download.

eekstein
Posts: 3
Joined: Tue 13 Sep 2011 15:23

Re: Get "Unable to cast" error when calling ExecuteArray

Post by eekstein » Thu 30 Aug 2012 22:37

Is this fix available for download yet?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Get "Unable to cast" error when calling ExecuteArray

Post by Pinturiccio » Mon 03 Sep 2012 13:53

No, the fix will be available in the next public build. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Get "Unable to cast" error when calling ExecuteArray

Post by Pinturiccio » Mon 10 Sep 2012 08:03

The new build of dotConnect for Oracle 7.2.77 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?t=24845

Post Reply