[Mono-list] Problem test example Mono and Oracle

Fernando Ike de Oliveira fernando at ikenet.com.br
Wed May 17 16:55:48 EDT 2006


Hi!

	I'm testing code example 1a in http://www.mono-project.com/Oracle and
build ok, but execute application return error "Unhandled Exception:
System.InvalidCastException: Cannot cast from source type to destination
type.
in [0x0003d] (at /home/fike/develop/mono/oracle/oracle/Main.cs:24)
oracle.MainClass:Main (System.String[] args".

	The code example:

// project created on 17/5/2006 at 15:15
using System;
using System.Data;
using System.Data.OracleClient;
namespace oracle
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string connectionString =
			"Data Source=tnsname;" +
			"User ID=user;" +
			"Password=pass;";
		OracleConnection dbcon = null;
		dbcon = new OracleConnection (connectionString);
		dbcon.Open ();
		OracleCommand dbcmd = dbcon.CreateCommand ();
		string sql = "select cdgprmalv, cdgprmprca from agata.atre3";
		dbcmd.CommandText = sql;
		OracleDataReader reader = dbcmd.ExecuteReader ();
		while (reader.Read ()) {
			string cdgprmalv = (string) reader["cdgprmalv"];
			string cdgprmprca = (string) reader["cdgprmprca"];
			Console.WriteLine("Cdgprmalv: {0} Cdgprmprca: {1}",
					cdgprmalv, cdgprmprca); 
		}

		reader.Close ();
		reader = null;
		dbcmd.CommandText = sql;
		dbcmd.ExecuteNonQuery ();
		dbcmd.Dispose ();
		dbcmd = null;
		dbcon.Close ();
		dbcon = null;
		}
	}
}

	What's happen? =)


[]'s
-- 
Fernando Ike - http://fike.homelinux.org:8088/cgi-bin/blosxom
Linux User 303638 - Debian User 352
Jabber - fike at jabber.org
I seek You (ICQ)- 160594996
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Esta =?ISO-8859-1?Q?=E9?= uma parte de mensagem
	assinada digitalmente
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20060517/9c43cb6c/attachment.bin


More information about the Mono-list mailing list